rapidkit 0.21.1 → 0.21.2

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/README.md CHANGED
@@ -377,7 +377,7 @@ my-service/
377
377
  ├── Dockerfile # Production container
378
378
  ├── Makefile # Quick commands
379
379
  ├── package.json # npm dependencies
380
- ├── yarn.lock / package-lock.json # Locked dependencies
380
+ ├── package-lock.json # Locked dependencies
381
381
  ├── nest-cli.json # NestJS CLI config
382
382
  ├── tsconfig.json # TypeScript config
383
383
  ├── tsconfig.build.json # Build config
@@ -625,7 +625,7 @@ npx rapidkit create --no-update-check # Skip version check
625
625
 
626
626
  **NestJS Projects:**
627
627
  - Node.js 20.19.6+
628
- - npm/yarn/pnpm
628
+ - npm
629
629
 
630
630
  ### Optional but Recommended
631
631
 
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import {d,c as c$1,g,a as a$1}from'./chunk-D2ZRDZOE.js';import {d as d$1,b as b$1}from'./chunk-RV6HBTFC.js';import {c,a,b}from'./chunk-7LU4Z66R.js';import {Command,Option}from'commander';import u from'chalk';import ue from'inquirer';import w from'path';import {exec,spawn}from'child_process';import S,{promises}from'fs';import*as Jt from'os';import Jt__default from'os';import {fileURLToPath,pathToFileURL}from'url';import Qt from'validate-npm-package-name';import*as k from'fs-extra';import k__default from'fs-extra';import {execa}from'execa';import Fe from'ora';import co from'nunjucks';import po from'crypto';import {promisify}from'util';var Bt=".rapidkitrc.json",Yt=["rapidkit.config.js","rapidkit.config.mjs","rapidkit.config.cjs"];async function z(){let e=w.join(Jt__default.homedir(),Bt);try{let o=await promises.readFile(e,"utf-8"),t=JSON.parse(o);return a.debug(`Loaded config from ${e}`),t}catch{return a.debug("No user config found, using defaults"),{}}}async function Ze(e=process.cwd()){let o=e,t=w.parse(o).root;for(;o!==t;){for(let n of Yt){let i=w.join(o,n);try{await promises.access(i),a.debug(`Found config file: ${i}`);let s=await import(pathToFileURL(i).href),c=s.default||s;return a.debug(`Loaded RapidKit config from ${n}`),c}catch{continue}}o=w.dirname(o);}return a.debug("No RapidKit config file found, using defaults"),{}}function et(e,o,t){return {author:t.author||o.workspace?.defaultAuthor||e.author,pythonVersion:o.workspace?.pythonVersion||e.pythonVersion,defaultInstallMethod:t.defaultInstallMethod||o.workspace?.installMethod||e.defaultInstallMethod,defaultKit:t.defaultKit||o.projects?.defaultKit||e.defaultKit,skipGit:t.skipGit??o.projects?.skipGit??e.skipGit,license:t.license||e.license,testRapidKitPath:t.testRapidKitPath||e.testRapidKitPath}}function he(e){return process.env.RAPIDKIT_DEV_PATH||e.testRapidKitPath||void 0}var F=class extends Error{constructor(t,n,i){super(t);this.code=n;this.details=i;this.name="RapidKitError",Error.captureStackTrace(this,this.constructor);}},Z=class extends F{constructor(o,t){let n=t?`Python ${o}+ required, found ${t}`:`Python ${o}+ not found`;super(n,"PYTHON_NOT_FOUND","Please install Python from https://www.python.org/downloads/");}},re=class extends F{constructor(){super("Poetry is not installed","POETRY_NOT_FOUND","Install Poetry from https://python-poetry.org/docs/#installation");}},se=class extends F{constructor(){super("pipx is not installed","PIPX_NOT_FOUND","Install pipx from https://pypa.github.io/pipx/installation/");}},ye=class extends F{constructor(o){super(`Directory "${o}" already exists`,"DIRECTORY_EXISTS","Please choose a different name or remove the existing directory");}},H=class extends F{constructor(o,t){super(`Invalid project name: "${o}"`,"INVALID_PROJECT_NAME",t);}},K=class extends F{constructor(o,t){let n=`Installation failed at: ${o}`,i=`${t.message}
2
+ import {d,c as c$1,g,a as a$1}from'./chunk-D2ZRDZOE.js';import {d as d$1,b as b$1}from'./chunk-RV6HBTFC.js';import {c,a,b}from'./chunk-7LU4Z66R.js';import {Command,Option}from'commander';import u from'chalk';import ue from'inquirer';import w from'path';import {exec,spawn}from'child_process';import S,{promises}from'fs';import*as zt from'os';import zt__default from'os';import {fileURLToPath,pathToFileURL}from'url';import Xt from'validate-npm-package-name';import*as k from'fs-extra';import k__default from'fs-extra';import {execa}from'execa';import Fe from'ora';import lo from'nunjucks';import uo from'crypto';import {promisify}from'util';var Yt=".rapidkitrc.json",Qt=["rapidkit.config.js","rapidkit.config.mjs","rapidkit.config.cjs"];async function z(){let e=w.join(zt__default.homedir(),Yt);try{let o=await promises.readFile(e,"utf-8"),t=JSON.parse(o);return a.debug(`Loaded config from ${e}`),t}catch{return a.debug("No user config found, using defaults"),{}}}async function Ze(e=process.cwd()){let o=e,t=w.parse(o).root;for(;o!==t;){for(let n of Qt){let i=w.join(o,n);try{await promises.access(i),a.debug(`Found config file: ${i}`);let s=await import(pathToFileURL(i).href),c=s.default||s;return a.debug(`Loaded RapidKit config from ${n}`),c}catch{continue}}o=w.dirname(o);}return a.debug("No RapidKit config file found, using defaults"),{}}function et(e,o,t){return {author:t.author||o.workspace?.defaultAuthor||e.author,pythonVersion:o.workspace?.pythonVersion||e.pythonVersion,defaultInstallMethod:t.defaultInstallMethod||o.workspace?.installMethod||e.defaultInstallMethod,defaultKit:t.defaultKit||o.projects?.defaultKit||e.defaultKit,skipGit:t.skipGit??o.projects?.skipGit??e.skipGit,license:t.license||e.license,testRapidKitPath:t.testRapidKitPath||e.testRapidKitPath}}function he(e){return process.env.RAPIDKIT_DEV_PATH||e.testRapidKitPath||void 0}var F=class extends Error{constructor(t,n,i){super(t);this.code=n;this.details=i;this.name="RapidKitError",Error.captureStackTrace(this,this.constructor);}},Z=class extends F{constructor(o,t){let n=t?`Python ${o}+ required, found ${t}`:`Python ${o}+ not found`;super(n,"PYTHON_NOT_FOUND","Please install Python from https://www.python.org/downloads/");}},re=class extends F{constructor(){super("Poetry is not installed","POETRY_NOT_FOUND","Install Poetry from https://python-poetry.org/docs/#installation");}},se=class extends F{constructor(){super("pipx is not installed","PIPX_NOT_FOUND","Install pipx from https://pypa.github.io/pipx/installation/");}},ye=class extends F{constructor(o){super(`Directory "${o}" already exists`,"DIRECTORY_EXISTS","Please choose a different name or remove the existing directory");}},H=class extends F{constructor(o,t){super(`Invalid project name: "${o}"`,"INVALID_PROJECT_NAME",t);}},K=class extends F{constructor(o,t){let n=`Installation failed at: ${o}`,i=`${t.message}
3
3
 
4
4
  Troubleshooting:
5
5
  - Check your internet connection
@@ -9,18 +9,18 @@ Troubleshooting:
9
9
  2. Use the core workflow: npx rapidkit create workspace <name>
10
10
  3. Offline fallback (limited): npx rapidkit create project fastapi.standard <name> --output .
11
11
 
12
- Legacy: set RAPIDKIT_SHOW_LEGACY=1 to reveal template-mode flags in help.`);}};function Me(e){let o=Qt(e);if(!o.validForNewPackages){let n=o.errors||[],i=o.warnings||[],r=[...n,...i];throw new H(e,`NPM validation failed: ${r.join(", ")}`)}if(!/^[a-z][a-z0-9_-]*$/.test(e))throw new H(e,"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(e.toLowerCase()))throw new H(e,`"${e}" is a reserved name. Please choose a different name.`);if(e.length<2)throw new H(e,"Name must be at least 2 characters long");if(e.length>214)throw new H(e,"Name must be less than 214 characters");return true}function Zt(e){return typeof e=="object"&&e!==null}async function eo(e,o,t,n=8e3){try{let i=await execa(e,o,{cwd:t,timeout:n,reject:false,stdio:"pipe"});return {ok:i.exitCode===0,exitCode:i.exitCode,stdout:i.stdout,stderr:i.stderr}}catch(i){return {ok:false,exitCode:void 0,stdout:"",stderr:i instanceof Error?i.message:String(i)}}}async function to(e,o){let t=["-m","rapidkit",...e],n=["python3","python"];for(let i of n){let r=await eo(i,t,o?.cwd,o?.timeoutMs);if(!r.ok)continue;let s=(r.stdout??"").trim();try{let c=JSON.parse(s);return Zt(c)?{ok:true,command:i,exitCode:r.exitCode,stdout:r.stdout,stderr:r.stderr,data:c}:{ok:false,command:i,exitCode:r.exitCode,stdout:r.stdout,stderr:r.stderr}}catch{return {ok:false,command:i,exitCode:r.exitCode,stdout:r.stdout,stderr:r.stderr}}}return {ok:false}}async function tt(e,o){let t=await to(["project","detect","--path",e,"--json"],o);return !t.ok||!t.data||t.data.schema_version!==1?{ok:false,command:t.command,exitCode:t.exitCode,stdout:t.stdout,stderr:t.stderr}:t}function we(){return process.platform==="win32"?"python":"python3"}async function it(e,o,t,n){let i=d$1(o,c(),t);n&&(i.metadata||(i.metadata={}),i.metadata.python={version:n}),await b$1(e,i);}async function rt(e){await k.outputFile(w.join(e,".gitignore"),`.venv/
12
+ Legacy: set RAPIDKIT_SHOW_LEGACY=1 to reveal template-mode flags in help.`);}};function Me(e){let o=Xt(e);if(!o.validForNewPackages){let n=o.errors||[],i=o.warnings||[],r=[...n,...i];throw new H(e,`NPM validation failed: ${r.join(", ")}`)}if(!/^[a-z][a-z0-9_-]*$/.test(e))throw new H(e,"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(e.toLowerCase()))throw new H(e,`"${e}" is a reserved name. Please choose a different name.`);if(e.length<2)throw new H(e,"Name must be at least 2 characters long");if(e.length>214)throw new H(e,"Name must be less than 214 characters");return true}function eo(e){return typeof e=="object"&&e!==null}async function to(e,o,t,n=8e3){try{let i=await execa(e,o,{cwd:t,timeout:n,reject:false,stdio:"pipe"});return {ok:i.exitCode===0,exitCode:i.exitCode,stdout:i.stdout,stderr:i.stderr}}catch(i){return {ok:false,exitCode:void 0,stdout:"",stderr:i instanceof Error?i.message:String(i)}}}async function oo(e,o){let t=["-m","rapidkit",...e],n=["python3","python"];for(let i of n){let r=await to(i,t,o?.cwd,o?.timeoutMs);if(!r.ok)continue;let s=(r.stdout??"").trim();try{let c=JSON.parse(s);return eo(c)?{ok:true,command:i,exitCode:r.exitCode,stdout:r.stdout,stderr:r.stderr,data:c}:{ok:false,command:i,exitCode:r.exitCode,stdout:r.stdout,stderr:r.stderr}}catch{return {ok:false,command:i,exitCode:r.exitCode,stdout:r.stdout,stderr:r.stderr}}}return {ok:false}}async function tt(e,o){let t=await oo(["project","detect","--path",e,"--json"],o);return !t.ok||!t.data||t.data.schema_version!==1?{ok:false,command:t.command,exitCode:t.exitCode,stdout:t.stdout,stderr:t.stderr}:t}function we(){return process.platform==="win32"?"python":"python3"}async function it(e,o,t,n){let i=d$1(o,c(),t);n&&(i.metadata||(i.metadata={}),i.metadata.python={version:n}),await b$1(e,i);}async function rt(e){await k.outputFile(w.join(e,".gitignore"),`.venv/
13
13
  __pycache__/
14
14
  *.pyc
15
15
  .env
16
16
  .rapidkit-workspace/
17
17
 
18
- `,"utf-8");}async function ot(e){try{let{stdout:o}=await execa(e,["--version"],{timeout:3e3}),t=o.match(/Python (\d+\.\d+\.\d+)/);if(t)return t[1]}catch{}return null}async function oo(e,o){try{await promises.writeFile(w.join(e,".python-version"),`${o}
19
- `,"utf-8"),a.debug(`Created .python-version with ${o}`);}catch(t){a.warn(`Failed to create .python-version: ${t}`);}}function ae(){let e=w.join(Jt.homedir(),".local","bin"),t=(process.env.PATH||"").split(w.delimiter).filter(Boolean);t.includes(e)||(process.env.PATH=[e,...t].join(w.delimiter));}async function ke(e,o){ae(),e.start("Checking pipx installation");try{return await execa("pipx",["--version"]),e.succeed("pipx found"),{kind:"binary"}}catch{}let t=we();try{return await execa(t,["-m","pipx","--version"]),e.succeed("pipx found"),{kind:"python-module",pythonCmd:t}}catch{}if(o)throw new se;let{installPipx:n}=await ue.prompt([{type:"confirm",name:"installPipx",message:"pipx is not installed. Install it now (user install via python -m pip)?",default:true}]);if(!n)throw new se;e.start("Installing pipx (user install)");try{try{await execa(t,["-m","pip","install","--user","--upgrade","pip"]);}catch{}await execa(t,["-m","pip","install","--user","--upgrade","pipx"]);}catch(i){let r=i,s=String(r?.stderr||r?.shortMessage||r?.message||"");throw new K("Install pipx with python -m pip",i instanceof Error?i:new Error(s))}e.succeed("pipx installed"),ae();try{return await execa(t,["-m","pipx","--version"]),{kind:"python-module",pythonCmd:t}}catch(i){let r=i,s=String(r?.stderr||r?.shortMessage||r?.message||"pipx not runnable after install");throw new K("Verify pipx after install",new Error(`${s}
18
+ `,"utf-8");}async function ot(e){try{let{stdout:o}=await execa(e,["--version"],{timeout:3e3}),t=o.match(/Python (\d+\.\d+\.\d+)/);if(t)return t[1]}catch{}return null}async function no(e,o){try{await promises.writeFile(w.join(e,".python-version"),`${o}
19
+ `,"utf-8"),a.debug(`Created .python-version with ${o}`);}catch(t){a.warn(`Failed to create .python-version: ${t}`);}}function ae(){let e=w.join(zt.homedir(),".local","bin"),t=(process.env.PATH||"").split(w.delimiter).filter(Boolean);t.includes(e)||(process.env.PATH=[e,...t].join(w.delimiter));}async function ke(e,o){ae(),e.start("Checking pipx installation");try{return await execa("pipx",["--version"]),e.succeed("pipx found"),{kind:"binary"}}catch{}let t=we();try{return await execa(t,["-m","pipx","--version"]),e.succeed("pipx found"),{kind:"python-module",pythonCmd:t}}catch{}if(o)throw new se;let{installPipx:n}=await ue.prompt([{type:"confirm",name:"installPipx",message:"pipx is not installed. Install it now (user install via python -m pip)?",default:true}]);if(!n)throw new se;e.start("Installing pipx (user install)");try{try{await execa(t,["-m","pip","install","--user","--upgrade","pip"]);}catch{}await execa(t,["-m","pip","install","--user","--upgrade","pipx"]);}catch(i){let r=i,s=String(r?.stderr||r?.shortMessage||r?.message||"");throw new K("Install pipx with python -m pip",i instanceof Error?i:new Error(s))}e.succeed("pipx installed"),ae();try{return await execa(t,["-m","pipx","--version"]),{kind:"python-module",pythonCmd:t}}catch(i){let r=i,s=String(r?.stderr||r?.shortMessage||r?.message||"pipx not runnable after install");throw new K("Verify pipx after install",new Error(`${s}
20
20
 
21
- Try reopening your terminal or run: python3 -m pipx ensurepath`))}}async function te(e,o){return e.kind==="binary"?execa("pipx",o):execa(e.pythonCmd,["-m","pipx",...o])}async function no(e,o){ae(),e.start("Checking Poetry installation");try{await execa("poetry",["--version"]),e.succeed("Poetry found");return}catch{}if(o)throw new re;let{installPoetry:t}=await ue.prompt([{type:"confirm",name:"installPoetry",message:"Poetry is not installed. Install it now using pipx?",default:true}]);if(!t)throw new re;let n=await ke(e,o);e.start("Installing Poetry with pipx");try{await te(n,["install","poetry"]);}catch(i){let r=i,s=String(r?.stderr||r?.shortMessage||r?.message||"");if(/already\s+installed|already\s+seems\s+to\s+be\s+installed|exists/i.test(s))try{await te(n,["upgrade","poetry"]);}catch{}else throw new K("Install Poetry with pipx",i instanceof Error?i:new Error(s))}e.succeed("Poetry installed"),ae();try{await execa("poetry",["--version"]);}catch(i){let r=i,s=String(r?.stderr||r?.shortMessage||r?.message||"Poetry not found on PATH");throw new K("Verify Poetry after pipx install",new Error(`${s}
21
+ Try reopening your terminal or run: python3 -m pipx ensurepath`))}}async function te(e,o){return e.kind==="binary"?execa("pipx",o):execa(e.pythonCmd,["-m","pipx",...o])}async function io(e,o){ae(),e.start("Checking Poetry installation");try{await execa("poetry",["--version"]),e.succeed("Poetry found");return}catch{}if(o)throw new re;let{installPoetry:t}=await ue.prompt([{type:"confirm",name:"installPoetry",message:"Poetry is not installed. Install it now using pipx?",default:true}]);if(!t)throw new re;let n=await ke(e,o);e.start("Installing Poetry with pipx");try{await te(n,["install","poetry"]);}catch(i){let r=i,s=String(r?.stderr||r?.shortMessage||r?.message||"");if(/already\s+installed|already\s+seems\s+to\s+be\s+installed|exists/i.test(s))try{await te(n,["upgrade","poetry"]);}catch{}else throw new K("Install Poetry with pipx",i instanceof Error?i:new Error(s))}e.succeed("Poetry installed"),ae();try{await execa("poetry",["--version"]);}catch(i){let r=i,s=String(r?.stderr||r?.shortMessage||r?.message||"Poetry not found on PATH");throw new K("Verify Poetry after pipx install",new Error(`${s}
22
22
 
23
- Poetry may be installed but not on PATH yet. Try reopening your terminal or run: pipx ensurepath`))}}function io(e){let o=e==="poetry";return `#!/usr/bin/env sh
23
+ Poetry may be installed but not on PATH yet. Try reopening your terminal or run: pipx ensurepath`))}}function ro(e){let o=e==="poetry";return `#!/usr/bin/env sh
24
24
  set -eu
25
25
 
26
26
  SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
@@ -39,7 +39,7 @@ echo "- If you used venv: ensure .venv exists (or re-run the installer)." 1>&2
39
39
  ${o?`echo "- If you used Poetry: run 'poetry install' and retry, or activate the env." 1>&2
40
40
  `:""}echo "Tip: you can also run: ./.venv/bin/rapidkit --help" 1>&2
41
41
  exit 1
42
- `}function ro(e){return `@echo off
42
+ `}function so(e){return `@echo off
43
43
  setlocal
44
44
 
45
45
  set "SCRIPT_DIR=%~dp0"
@@ -58,14 +58,14 @@ if %ERRORLEVEL%==0 if exist "%SCRIPT_DIR%\\pyproject.toml" (
58
58
  `:""}echo RapidKit launcher could not find a local Python CLI. 1>&2
59
59
  echo Tip: run .venv\\Scripts\\rapidkit.exe --help 1>&2
60
60
  exit /b 1
61
- `}async function st(e,o){await k.outputFile(w.join(e,"rapidkit"),io(o),{encoding:"utf-8",mode:493}),await k.outputFile(w.join(e,"rapidkit.cmd"),ro(o),"utf-8");}async function ve(e,o){let{skipGit:t=false,testMode:n=false,demoMode:i=false,dryRun:r=false,yes:s=false,userConfig:c={},installMethod:a$1}=o,l=e||"rapidkit",d=w.resolve(process.cwd(),l);if(await k.pathExists(d))throw new ye(l);if(r){await ao(d,l,i,c);return}if(i){await so(d,l,t);return}let m=s?{pythonVersion:c.pythonVersion||"3.10",installMethod:a$1||c.defaultInstallMethod||"poetry"}:await ue.prompt([{type:"list",name:"pythonVersion",message:"Select Python version for RapidKit:",choices:["3.10","3.11","3.12"],default:c.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:c.defaultInstallMethod||"poetry"}]);a.step(1,3,"Setting up RapidKit environment");let p=Fe("Creating directory").start();try{await k.ensureDir(d),p.succeed("Directory created"),p.start("Detecting Python version");let y=null,P=await at(m.pythonVersion);if(P)y=await ot(P),y?(a.info(` Detected Python ${y}`),p.succeed(`Python ${y} detected`)):p.warn("Could not detect exact Python version");else {let v=we();y=await ot(v),y?p.succeed(`Python ${y} detected`):p.warn("Could not detect Python version, proceeding with defaults");}if(await it(d,l,m.installMethod,y||void 0),y&&await oo(d,y),await rt(d),m.installMethod==="poetry")try{await ct(d,m.pythonVersion,p,n,c,s);}catch(v){let C=v?.details||v?.message||String(v);if(C.includes("pyenv")||C.includes("exit status 127")||C.includes("returned non-zero exit status 127")){p.warn("Poetry encountered Python discovery issues, trying venv method"),a.debug(`Poetry error (attempting venv fallback): ${C}`);try{await De(d,m.pythonVersion,p,n,c),m.installMethod="venv";}catch(M){throw M}}else throw v}else m.installMethod==="venv"?await De(d,m.pythonVersion,p,n,c):await lt(d,p,n,c,s);if(await st(d,m.installMethod),await dt(d,m.installMethod),p.succeed("RapidKit environment ready!"),!o.skipGit){p.start("Initializing git repository");try{await execa("git",["init"],{cwd:d}),await execa("git",["add","."],{cwd:d}),await execa("git",["commit","-m","Initial commit: RapidKit environment"],{cwd:d}),p.succeed("Git repository initialized");}catch{p.warn("Could not initialize git repository");}}try{let{registerWorkspace:v}=await import('./workspace-LZZGJRGV.js');await v(d,l);}catch{console.warn(u.gray("Note: Could not register workspace in shared registry"));}if(console.log(u.green(`
61
+ `}async function st(e,o){await k.outputFile(w.join(e,"rapidkit"),ro(o),{encoding:"utf-8",mode:493}),await k.outputFile(w.join(e,"rapidkit.cmd"),so(o),"utf-8");}async function ve(e,o){let{skipGit:t=false,testMode:n=false,demoMode:i=false,dryRun:r=false,yes:s=false,userConfig:c={},installMethod:a$1}=o,l=e||"rapidkit",d=w.resolve(process.cwd(),l);if(await k.pathExists(d))throw new ye(l);if(r){await co(d,l,i,c);return}if(i){await ao(d,l,t);return}let m=s?{pythonVersion:c.pythonVersion||"3.10",installMethod:a$1||c.defaultInstallMethod||"poetry"}:await ue.prompt([{type:"list",name:"pythonVersion",message:"Select Python version for RapidKit:",choices:["3.10","3.11","3.12"],default:c.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:c.defaultInstallMethod||"poetry"}]);a.step(1,3,"Setting up RapidKit environment");let p=Fe("Creating directory").start();try{await k.ensureDir(d),p.succeed("Directory created"),p.start("Detecting Python version");let y=null,P=await at(m.pythonVersion);if(P)y=await ot(P),y?(a.info(` Detected Python ${y}`),p.succeed(`Python ${y} detected`)):p.warn("Could not detect exact Python version");else {let v=we();y=await ot(v),y?p.succeed(`Python ${y} detected`):p.warn("Could not detect Python version, proceeding with defaults");}if(await it(d,l,m.installMethod,y||void 0),y&&await no(d,y),await rt(d),m.installMethod==="poetry")try{await ct(d,m.pythonVersion,p,n,c,s);}catch(v){let C=v?.details||v?.message||String(v);if(C.includes("pyenv")||C.includes("exit status 127")||C.includes("returned non-zero exit status 127")){p.warn("Poetry encountered Python discovery issues, trying venv method"),a.debug(`Poetry error (attempting venv fallback): ${C}`);try{await De(d,m.pythonVersion,p,n,c),m.installMethod="venv";}catch(M){throw M}}else throw v}else m.installMethod==="venv"?await De(d,m.pythonVersion,p,n,c):await lt(d,p,n,c,s);if(await st(d,m.installMethod),await dt(d,m.installMethod),p.succeed("RapidKit environment ready!"),!o.skipGit){p.start("Initializing git repository");try{await execa("git",["init"],{cwd:d}),await execa("git",["add","."],{cwd:d}),await execa("git",["commit","-m","Initial commit: RapidKit environment"],{cwd:d}),p.succeed("Git repository initialized");}catch{p.warn("Could not initialize git repository");}}try{let{registerWorkspace:v}=await import('./workspace-LZZGJRGV.js');await v(d,l);}catch{console.warn(u.gray("Note: Could not register workspace in shared registry"));}if(console.log(u.green(`
62
62
  \u2728 RapidKit environment created successfully!
63
63
  `)),console.log(u.cyan("\u{1F4C2} Location:"),u.white(d)),console.log(u.cyan(`\u{1F680} Get started:
64
- `)),console.log(u.white(` cd ${l}`)),m.installMethod==="poetry"){let v="source $(poetry env info --path)/bin/activate";try{ae();let{stdout:C}=await execa("poetry",["--version"]),_=C.match(/Poetry.*?(\d+)\.(\d+)/);_&&(parseInt(_[1])>=2?v="source $(poetry env info --path)/bin/activate":v="poetry shell");}catch{}console.log(u.white(` ${v} # Or: poetry run rapidkit`)),console.log(u.white(" rapidkit create # Interactive mode")),console.log(u.white(" cd <project-name> && rapidkit init && rapidkit dev"));}else m.installMethod==="venv"?(console.log(u.white(" source .venv/bin/activate # On Windows: .venv\\Scripts\\activate")),console.log(u.white(" rapidkit create # Interactive mode")),console.log(u.white(" cd <project-name> && rapidkit init && rapidkit dev"))):(console.log(u.white(" rapidkit create # Interactive mode")),console.log(u.white(" cd <project-name> && rapidkit init && rapidkit dev")));console.log(u.white(`
64
+ `)),console.log(u.white(` cd ${l}`)),m.installMethod==="poetry"){let v="source $(poetry env info --path)/bin/activate";try{ae();let{stdout:C}=await execa("poetry",["--version"]),E=C.match(/Poetry.*?(\d+)\.(\d+)/);E&&(parseInt(E[1])>=2?v="source $(poetry env info --path)/bin/activate":v="poetry shell");}catch{}console.log(u.white(` ${v} # Or: poetry run rapidkit`)),console.log(u.white(" rapidkit create # Interactive mode")),console.log(u.white(" cd <project-name> && rapidkit init && rapidkit dev"));}else m.installMethod==="venv"?(console.log(u.white(" source .venv/bin/activate # On Windows: .venv\\Scripts\\activate")),console.log(u.white(" rapidkit create # Interactive mode")),console.log(u.white(" cd <project-name> && rapidkit init && rapidkit dev"))):(console.log(u.white(" rapidkit create # Interactive mode")),console.log(u.white(" cd <project-name> && rapidkit init && rapidkit dev")));console.log(u.white(`
65
65
  \u{1F4A1} For more information, check the README.md file.`)),console.log(u.cyan(`
66
66
  \u{1F4DA} RapidKit commands:`)),console.log(u.white(" rapidkit create - Create a new project (interactive)")),console.log(u.white(" rapidkit dev - Run development server")),console.log(u.white(" rapidkit add module <name> - Add a module (e.g., settings)")),console.log(u.white(" rapidkit list - List available kits")),console.log(u.white(" rapidkit modules - List available modules")),console.log(u.white(` rapidkit --help - Show all commands
67
67
  `));}catch(y){p.fail("Failed to create RapidKit environment"),console.error(u.red(`
68
- \u274C Error:`),y);try{await k.remove(d);}catch{}throw y}}async function at(e){let o=[];try{let{stdout:t}=await execa("pyenv",["root"]),n=t.trim();o.push(w.join(n,"versions",`${e}.*`,"bin","python"));let[i,r]=e.split(".");o.push(w.join(n,"versions",`${i}.${r}.*`,"bin","python"));}catch{}o.push(`python${e}`,`python3.${e.split(".")[1]}`,"python3","python"),o.push(`/usr/bin/python${e}`,"/usr/bin/python3",`/usr/local/bin/python${e}`,"/usr/local/bin/python3");for(let t of o)try{let n=t;if(t.includes("*")){if(n=(await execa("sh",["-c",`ls -d ${t} 2>/dev/null | head -1`])).stdout.trim(),!n)continue;n=w.join(n.split("/").slice(0,-1).join("/"),"../bin/python");}let{stdout:i}=await execa(n,["--version"],{timeout:2e3}),r=i.match(/Python (\d+\.\d+)/)?.[1];if(r&&parseFloat(r)>=parseFloat(e))return await execa(n,["-c","import sys; sys.exit(0)"],{timeout:2e3}),n}catch{continue}return null}async function ct(e,o,t,n,i,r=false){await no(t,r),t.start("Finding Python interpreter");let s=await at(o);s?(a.debug(`Found working Python: ${s}`),t.succeed("Python found")):t.warn("Could not verify Python path, proceeding with default"),t.start("Initializing Poetry project"),await execa("poetry",["init","--no-interaction","--python",`^${o}`],{cwd:e}),t.succeed("Poetry project initialized");let c=w.join(e,"pyproject.toml"),l=await promises.readFile(c,"utf-8");l.includes("[tool.poetry]")?l=l.replace("[tool.poetry]",`[tool.poetry]
68
+ \u274C Error:`),y);try{await k.remove(d);}catch{}throw y}}async function at(e){let o=[];try{let{stdout:t}=await execa("pyenv",["root"]),n=t.trim();o.push(w.join(n,"versions",`${e}.*`,"bin","python"));let[i,r]=e.split(".");o.push(w.join(n,"versions",`${i}.${r}.*`,"bin","python"));}catch{}o.push(`python${e}`,`python3.${e.split(".")[1]}`,"python3","python"),o.push(`/usr/bin/python${e}`,"/usr/bin/python3",`/usr/local/bin/python${e}`,"/usr/local/bin/python3");for(let t of o)try{let n=t;if(t.includes("*")){if(n=(await execa("sh",["-c",`ls -d ${t} 2>/dev/null | head -1`])).stdout.trim(),!n)continue;n=w.join(n.split("/").slice(0,-1).join("/"),"../bin/python");}let{stdout:i}=await execa(n,["--version"],{timeout:2e3}),r=i.match(/Python (\d+\.\d+)/)?.[1];if(r&&parseFloat(r)>=parseFloat(e))return await execa(n,["-c","import sys; sys.exit(0)"],{timeout:2e3}),n}catch{continue}return null}async function ct(e,o,t,n,i,r=false){await io(t,r),t.start("Finding Python interpreter");let s=await at(o);s?(a.debug(`Found working Python: ${s}`),t.succeed("Python found")):t.warn("Could not verify Python path, proceeding with default"),t.start("Initializing Poetry project"),await execa("poetry",["init","--no-interaction","--python",`^${o}`],{cwd:e}),t.succeed("Poetry project initialized");let c=w.join(e,"pyproject.toml"),l=await promises.readFile(c,"utf-8");l.includes("[tool.poetry]")?l=l.replace("[tool.poetry]",`[tool.poetry]
69
69
  package-mode = false`):l.includes("[project]")&&(l.includes("[build-system]")?l=l.replace("[build-system]",`
70
70
  [tool.poetry]
71
71
  package-mode = false
@@ -204,7 +204,7 @@ If you encounter issues:
204
204
  2. Check RapidKit installation: \`rapidkit --version\`
205
205
  3. Run diagnostics: \`rapidkit doctor\`
206
206
  4. Visit RapidKit documentation or GitHub issues
207
- `;await promises.writeFile(w.join(e,"README.md"),i,"utf-8");}async function so(e,o,t){let n=Fe("Creating demo workspace").start();try{await k.ensureDir(e),n.succeed("Directory created"),n.start("Setting up demo kit generator");let i=JSON.stringify({name:`${o}-workspace`,version:"1.0.0",private:true,description:"RapidKit demo workspace",scripts:{generate:"node generate-demo.js"}},null,2);await promises.writeFile(w.join(e,"package.json"),i,"utf-8"),await promises.writeFile(w.join(e,"generate-demo.js"),`#!/usr/bin/env node
207
+ `;await promises.writeFile(w.join(e,"README.md"),i,"utf-8");}async function ao(e,o,t){let n=Fe("Creating demo workspace").start();try{await k.ensureDir(e),n.succeed("Directory created"),n.start("Setting up demo kit generator");let i=JSON.stringify({name:`${o}-workspace`,version:"1.0.0",private:true,description:"RapidKit demo workspace",scripts:{generate:"node generate-demo.js"}},null,2);await promises.writeFile(w.join(e,"package.json"),i,"utf-8"),await promises.writeFile(w.join(e,"generate-demo.js"),`#!/usr/bin/env node
208
208
  /**
209
209
  * Demo Kit Generator - Create FastAPI demo projects
210
210
  *
@@ -703,7 +703,7 @@ __pycache__/
703
703
  `,"utf-8"),await execa("git",["add","."],{cwd:e}),await execa("git",["commit","-m","Initial commit: Demo workspace"],{cwd:e}),n.succeed("Git repository initialized");}catch{n.warn("Could not initialize git repository");}}console.log(u.green(`
704
704
  \u2728 Demo workspace created successfully!
705
705
  `)),console.log(u.cyan("\u{1F4C2} Location:"),u.white(e)),console.log(u.cyan(`\u{1F680} Get started:
706
- `)),console.log(u.white(` cd ${o}`)),console.log(u.white(" node generate-demo.js my-api")),console.log(u.white(" cd my-api")),console.log(u.white(" rapidkit init")),console.log(u.white(" rapidkit dev")),console.log(),console.log(u.yellow("\u{1F4A1} Note:"),"This is a demo workspace. For full RapidKit features:"),console.log(u.cyan(" pipx install rapidkit")),console.log();}catch(i){throw n.fail("Failed to create demo workspace"),i}}async function ao(e,o,t,n){console.log(u.cyan(`
706
+ `)),console.log(u.white(` cd ${o}`)),console.log(u.white(" node generate-demo.js my-api")),console.log(u.white(" cd my-api")),console.log(u.white(" rapidkit init")),console.log(u.white(" rapidkit dev")),console.log(),console.log(u.yellow("\u{1F4A1} Note:"),"This is a demo workspace. For full RapidKit features:"),console.log(u.cyan(" pipx install rapidkit")),console.log();}catch(i){throw n.fail("Failed to create demo workspace"),i}}async function co(e,o,t,n){console.log(u.cyan(`
707
707
  \u{1F50D} Dry-run mode - showing what would be created:
708
708
  `)),console.log(u.white("\u{1F4C2} Project path:"),e),console.log(u.white("\u{1F4E6} Project type:"),t?"Demo workspace":"Full RapidKit environment"),t?(console.log(u.white(`
709
709
  \u{1F4DD} Files to create:`)),console.log(u.gray(" - package.json")),console.log(u.gray(" - generate-demo.js (project generator)")),console.log(u.gray(" - README.md")),console.log(u.gray(" - .gitignore")),console.log(u.white(`
@@ -712,7 +712,7 @@ __pycache__/
712
712
  \u{1F4DD} Files to create:`)),console.log(u.gray(" - pyproject.toml (Poetry) or .venv/ (venv)")),console.log(u.gray(" - README.md")),console.log(u.gray(" - .gitignore")),console.log(u.white(`
713
713
  \u{1F3AF} Next steps after creation:`)),console.log(u.gray(" 1. Install RapidKit Python package")),console.log(u.gray(" 2. Create projects with rapidkit CLI")),console.log(u.gray(" 3. Add modules and customize"))),console.log(u.white(`
714
714
  \u{1F4A1} To proceed with actual creation, run without --dry-run flag
715
- `));}var uo=fileURLToPath(import.meta.url),mo=w.dirname(uo);function go(e=32){let o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=po.randomBytes(e),n="";for(let i=0;i<e;i++)n+=o[t[i]%o.length];return n}async function pt(e,o){let t=o.template||"fastapi",n=t==="fastapi",i=n?"FastAPI":"NestJS",r=Fe(`Generating ${i} project...`).start();try{let s=w.resolve(mo,".."),c$1=o.kit_name||`${t}.standard`,a;c$1==="fastapi.ddd"?a="fastapi-ddd":c$1.startsWith("fastapi")?a="fastapi-standard":a="nestjs-standard";let l=w.join(s,"templates","kits",a),d=co.configure(l,{autoescape:false,trimBlocks:true,lstripBlocks:true});d.addFilter("generate_secret",function(v,C=32){return go(C)});let m={project_name:o.project_name,author:o.author||"RapidKit User",description:o.description||(n?"FastAPI service generated with RapidKit":"NestJS application generated with RapidKit"),app_version:o.app_version||"0.1.0",license:o.license||"MIT",package_manager:o.package_manager||"npm",node_version:o.node_version||"20.0.0",database_type:o.database_type||"postgresql",include_caching:o.include_caching||false,created_at:new Date().toISOString(),rapidkit_version:c()},p;n?p=["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"]:p=["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 v of p){let C=w.join(l,v);try{await promises.access(C);}catch{continue}let _=await promises.readFile(C,"utf-8"),M;try{M=d.renderString(_,m);}catch(qt){throw console.error(`Failed to render template: ${v}`),qt}let U=v.replace(/\.j2$/,""),Se=w.join(e,U);await promises.mkdir(w.dirname(Se),{recursive:true}),await promises.writeFile(Se,M),(U.endsWith(".rapidkit/rapidkit")||U.endsWith(".rapidkit/cli.py")||U.endsWith(".rapidkit/activate")||U==="rapidkit")&&await promises.chmod(Se,493);}if(n){let v=w.join(l,".rapidkit","context.json"),C=w.join(e,".rapidkit","context.json");try{await promises.mkdir(w.join(e,".rapidkit"),{recursive:true}),await promises.copyFile(v,C);}catch{await promises.mkdir(w.join(e,".rapidkit"),{recursive:true});let M=o.engine||"pip";await promises.writeFile(C,JSON.stringify({engine:M,created_by:"rapidkit-npm-fallback"},null,2));}}let y=n?`# Python
715
+ `));}var mo=fileURLToPath(import.meta.url),go=w.dirname(mo);function fo(e=32){let o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=uo.randomBytes(e),n="";for(let i=0;i<e;i++)n+=o[t[i]%o.length];return n}async function pt(e,o){let t=o.template||"fastapi",n=t==="fastapi",i=n?"FastAPI":"NestJS",r=Fe(`Generating ${i} project...`).start();try{let s=w.resolve(go,".."),c$1=o.kit_name||`${t}.standard`,a;c$1==="fastapi.ddd"?a="fastapi-ddd":c$1.startsWith("fastapi")?a="fastapi-standard":a="nestjs-standard";let l=w.join(s,"templates","kits",a),d=lo.configure(l,{autoescape:false,trimBlocks:true,lstripBlocks:true});d.addFilter("generate_secret",function(v,C=32){return fo(C)});let m={project_name:o.project_name,author:o.author||"RapidKit User",description:o.description||(n?"FastAPI service generated with RapidKit":"NestJS application generated with RapidKit"),app_version:o.app_version||"0.1.0",license:o.license||"MIT",package_manager:o.package_manager||"npm",node_version:o.node_version||"20.0.0",database_type:o.database_type||"postgresql",include_caching:o.include_caching||false,created_at:new Date().toISOString(),rapidkit_version:c()},p;n?p=["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"]:p=["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 v of p){let C=w.join(l,v);try{await promises.access(C);}catch{continue}let E=await promises.readFile(C,"utf-8"),M;try{M=d.renderString(E,m);}catch(Jt){throw console.error(`Failed to render template: ${v}`),Jt}let U=v.replace(/\.j2$/,""),Se=w.join(e,U);await promises.mkdir(w.dirname(Se),{recursive:true}),await promises.writeFile(Se,M),(U.endsWith(".rapidkit/rapidkit")||U.endsWith(".rapidkit/cli.py")||U.endsWith(".rapidkit/activate")||U==="rapidkit")&&await promises.chmod(Se,493);}if(n){let v=w.join(l,".rapidkit","context.json"),C=w.join(e,".rapidkit","context.json");try{await promises.mkdir(w.join(e,".rapidkit"),{recursive:true}),await promises.copyFile(v,C);}catch{await promises.mkdir(w.join(e,".rapidkit"),{recursive:true});let M=o.engine||"pip";await promises.writeFile(C,JSON.stringify({engine:M,created_by:"rapidkit-npm-fallback"},null,2));}}let y=n?`# Python
716
716
  __pycache__/
717
717
  *.py[cod]
718
718
  *$py.class
@@ -852,7 +852,7 @@ ${u.bold("\u{1F310} API endpoints:")}
852
852
 
853
853
  ${u.gray("Alternative: npm run start:dev, ./rapidkit dev")}
854
854
  ${u.gray("\u{1F4A1} Tip: Install globally (npm i -g rapidkit) to use without npx")}
855
- `);}catch(s){throw r.fail(`Failed to generate ${i} project`),s}}async function mt(){let e=process.platform==="win32"?["python","python3"]:["python3","python"];for(let o of e)try{let{stdout:t}=await execa(o,["--version"],{timeout:3e3}),n=t.match(/Python (\d+\.\d+\.\d+)/);if(n){let i=n[1],[r,s]=i.split(".").map(Number);return r<3||r===3&&s<10?{status:"warn",message:`Python ${i} (requires 3.10+)`,details:`${o} found but version is below minimum requirement`}:{status:"ok",message:`Python ${i}`,details:`Using ${o}`}}}catch{continue}return {status:"error",message:"Python not found",details:"Install Python 3.10+ and ensure it's in PATH"}}async function gt(){try{let{stdout:e}=await execa("poetry",["--version"],{timeout:3e3}),o=e.match(/Poetry .*version ([\d.]+)/);return o?{status:"ok",message:`Poetry ${o[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 ft(){try{let{stdout:e}=await execa("pipx",["--version"],{timeout:3e3});return {status:"ok",message:`pipx ${e.trim()}`,details:"Available for global tool installation"}}catch{return {status:"warn",message:"pipx not installed",details:"Optional: Install for isolated Python tools"}}}async function ht(){let e=process.env.HOME||process.env.USERPROFILE||"",o=[],t=[{location:"Global (pipx)",path:w.join(e,".local","bin","rapidkit")},{location:"Global (pipx)",path:w.join(e,"AppData","Roaming","Python","Scripts","rapidkit.exe")},{location:"Global (pyenv)",path:w.join(e,".pyenv","shims","rapidkit")},{location:"Global (system)",path:"/usr/local/bin/rapidkit"},{location:"Global (system)",path:"/usr/bin/rapidkit"}],n=[{location:"Workspace (.venv)",path:w.join(process.cwd(),".venv","bin","rapidkit")},{location:"Workspace (.venv)",path:w.join(process.cwd(),".venv","Scripts","rapidkit.exe")}];for(let{location:r,path:s}of [...t,...n])try{if(await k__default.pathExists(s)){let{stdout:c,exitCode:a}=await execa(s,["--version"],{timeout:3e3,reject:false});if(a===0&&(c.includes("RapidKit Version")||c.includes("RapidKit"))){let l=c.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);l&&o.push({location:r,path:s,version:l[1]});}}}catch{continue}if(o.length>0)return {status:"ok",message:`RapidKit Core ${o[0].version}`,paths:o.map(s=>({location:s.location,path:s.path,version:s.version}))};try{let{stdout:r,exitCode:s}=await execa("rapidkit",["--version"],{timeout:3e3,reject:false});if(s===0&&(r.includes("RapidKit Version")||r.includes("RapidKit"))){let c=r.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(c)return {status:"ok",message:`RapidKit Core ${c[1]}`,details:"Available via PATH"}}}catch{}try{let{stdout:r,exitCode:s}=await execa("poetry",["run","rapidkit","--version"],{timeout:3e3,reject:false});if(s===0&&(r.includes("RapidKit Version")||r.includes("RapidKit"))){let c=r.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(c)return {status:"ok",message:`RapidKit Core ${c[1]}`,details:"Available via Poetry"}}}catch{}let i=process.platform==="win32"?["python","python3"]:["python3","python"];for(let r of i)try{let{stdout:s,exitCode:c}=await execa(r,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:3e3,reject:false});if(c===0&&s&&!s.includes("Traceback")&&!s.includes("ModuleNotFoundError")){let a=s.trim();if(a)return {status:"ok",message:`RapidKit Core ${a}`,details:`Available in ${r} environment`}}}catch{continue}return {status:"error",message:"RapidKit Core not installed",details:"Install with: pipx install rapidkit-core"}}async function Te(e,o){let t=w.join(e,"Dockerfile");o.hasDocker=await k__default.pathExists(t);let n=w.join(e,"tests"),i=w.join(e,"test");if(o.hasTests=await k__default.pathExists(n)||await k__default.pathExists(i),o.framework==="NestJS"){let r=w.join(e,".eslintrc.js"),s=w.join(e,".eslintrc.json");o.hasCodeQuality=await k__default.pathExists(r)||await k__default.pathExists(s);}else if(o.framework==="FastAPI"){let r=w.join(e,"ruff.toml"),s=w.join(e,"pyproject.toml");if(await k__default.pathExists(s))try{let c=await k__default.readFile(s,"utf8");o.hasCodeQuality=c.includes("[tool.ruff]")||await k__default.pathExists(r);}catch{o.hasCodeQuality=await k__default.pathExists(r);}}try{if(o.framework==="NestJS"){let{stdout:r}=await execa("npm",["audit","--json"],{cwd:e,reject:false});if(r)try{let c=JSON.parse(r).metadata?.vulnerabilities;c&&(o.vulnerabilities=(c.high||0)+(c.critical||0)+(c.moderate||0));}catch{}}else if(o.framework==="FastAPI"){let r=w.join(e,".venv"),s=process.platform==="win32"?w.join(r,"Scripts","python.exe"):w.join(r,"bin","python");if(await k__default.pathExists(s))try{let{stdout:c}=await execa(s,["-m","pip","list","--format=json"],{timeout:5e3,reject:false});if(c){JSON.parse(c);o.vulnerabilities=0;}}catch{}}}catch{}}async function ho(e){let t={name:w.basename(e),path:e,venvActive:false,depsInstalled:false,coreInstalled:false,issues:[],fixCommands:[]},n=w.join(e,".rapidkit");if(!await k__default.pathExists(n))return t.issues.push("Not a valid RapidKit project (missing .rapidkit directory)"),t;try{let a=w.join(e,"registry.json");if(await k__default.pathExists(a)){let l=await k__default.readJson(a);l.installed_modules&&(t.stats={modules:l.installed_modules.length});}}catch{}try{let a=w.join(n,"project.json");if(await k__default.pathExists(a)){let l=await k__default.readJson(a);l.kit&&(t.kit=l.kit);}}catch{}try{let a=w.join(e,".git");if(await k__default.pathExists(a)){let{stdout:l}=await execa("git",["log","-1","--format=%cr"],{cwd:e,reject:false});l&&(t.lastModified=l.trim());}else {let l=await k__default.stat(e),m=Date.now()-l.mtime.getTime(),p=Math.floor(m/(1e3*60*60*24));t.lastModified=p===0?"today":`${p} day${p>1?"s":""} ago`;}}catch{}let i=w.join(e,"package.json"),r=w.join(e,"pyproject.toml"),s=await k__default.pathExists(i),c=await k__default.pathExists(r);if(s){t.framework="NestJS",t.venvActive=true;let a=w.join(e,"node_modules");if(await k__default.pathExists(a))try{let p=(await k__default.readdir(a)).filter(y=>!y.startsWith(".")&&!y.startsWith("_"));t.depsInstalled=p.length>0;}catch{t.depsInstalled=false;}t.depsInstalled||(t.issues.push("Dependencies not installed (node_modules empty or missing)"),t.fixCommands?.push(`cd ${e} && rapidkit init`)),t.coreInstalled=false;let l=w.join(e,".env");if(t.hasEnvFile=await k__default.pathExists(l),!t.hasEnvFile){let m=w.join(e,".env.example");await k__default.pathExists(m)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(`cd ${e} && cp .env.example .env`));}let d=w.join(e,"src");if(t.modulesHealthy=true,t.missingModules=[],await k__default.pathExists(d))try{let m=await k__default.readdir(d);t.modulesHealthy=m.length>0;}catch{t.modulesHealthy=false;}return await Te(e,t),t}if(c){t.framework="FastAPI";let a=w.join(e,".venv");if(await k__default.pathExists(a)){t.venvActive=true;let p=process.platform==="win32"?w.join(a,"Scripts","python.exe"):w.join(a,"bin","python");if(await k__default.pathExists(p)){try{let{stdout:y}=await execa(p,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:2e3});t.coreInstalled=true,t.coreVersion=y.trim();}catch{t.coreInstalled=false;}try{await execa(p,["-c","import fastapi"],{timeout:2e3}),t.depsInstalled=true;}catch{try{let y=w.join(a,"lib");if(await k__default.pathExists(y)){let v=(await k__default.readdir(y)).find(C=>C.startsWith("python"));if(v){let C=w.join(y,v,"site-packages");if(await k__default.pathExists(C)){let M=(await k__default.readdir(C)).filter(U=>!U.startsWith("_")&&!U.includes("dist-info")&&!["pip","setuptools","wheel","pkg_resources"].includes(U));t.depsInstalled=M.length>0;}}}t.depsInstalled||(t.issues.push("Dependencies not installed"),t.fixCommands?.push(`cd ${e} && rapidkit init`));}catch{t.issues.push("Could not verify dependency installation");}}}else t.issues.push("Virtual environment exists but Python executable not found");}else t.issues.push("Virtual environment not created"),t.fixCommands?.push(`cd ${e} && rapidkit init`);let l=w.join(e,".env");if(t.hasEnvFile=await k__default.pathExists(l),!t.hasEnvFile){let p=w.join(e,".env.example");await k__default.pathExists(p)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(`cd ${e} && cp .env.example .env`));}let d=w.join(e,"src"),m=w.join(e,"modules");if(t.modulesHealthy=true,t.missingModules=[],await k__default.pathExists(d)){let p=w.join(d,"__init__.py");await k__default.pathExists(p)||(t.modulesHealthy=false,t.missingModules.push("src/__init__.py"));}if(await k__default.pathExists(m))try{let p=await yt(m);for(let y of p){let P=w.join(m,y,"__init__.py");await k__default.pathExists(P)||(t.modulesHealthy=false,t.missingModules.push(`modules/${y}/__init__.py`));}}catch{}return !t.modulesHealthy&&t.missingModules.length>0&&t.issues.push(`Missing module init files: ${t.missingModules.join(", ")}`),await Te(e,t),t}return t.issues.push("Unknown project type (no package.json or pyproject.toml)"),await Te(e,t),t}async function yt(e){try{return (await k__default.readdir(e,{withFileTypes:true})).filter(t=>t.isDirectory()).map(t=>t.name)}catch{try{let o=await k__default.readdir(e),t=[];for(let n of o)try{(await k__default.stat(w.join(e,n))).isDirectory()&&t.push(n);}catch{continue}return t}catch{return []}}}async function Ne(e){let o=w.join(e,".rapidkit");if(!await k__default.pathExists(o))return false;let t=["project.json","context.json","file-hashes.json"];for(let n of t)if(await k__default.pathExists(w.join(o,n)))return true;return false}async function yo(e,o,t){let n=new Set,i=[{dir:e,depth:0}];for(;i.length>0;){let r=i.shift();if(!r)break;try{let s=await k__default.readdir(r.dir);for(let c of s){if(t.has(c))continue;let a=w.join(r.dir,c),l;try{l=await k__default.stat(a);}catch{continue}if(l.isDirectory()){if(await Ne(a)){n.add(a);continue}r.depth<o&&i.push({dir:a,depth:r.depth+1});}}}catch{continue}}return Array.from(n)}async function wo(e){let o=e,t=w.parse(o).root;for(;o!==t;){let n=[w.join(o,".rapidkit-workspace"),w.join(o,".rapidkit","workspace-marker.json"),w.join(o,".rapidkit","config.json")];for(let i of n)if(await k__default.pathExists(i))return o;o=w.dirname(o);}return null}function ko(e,o){let t=0,n=0,i=0;return e.forEach(s=>{s.status==="ok"?t++:s.status==="warn"?n++:s.status==="error"&&i++;}),o.forEach(s=>{s.issues.length===0&&s.venvActive&&s.depsInstalled?t++:s.issues.length>0&&n++;}),{total:t+n+i,passed:t,warnings:n,errors:i}}async function vo(e){let o=w.basename(e);try{let i=w.join(e,".rapidkit-workspace");await k__default.pathExists(i)&&(o=(await k__default.readJSON(i)).name||o);}catch{try{let i=w.join(e,".rapidkit","config.json");o=(await k__default.readJSON(i)).workspace_name||o;}catch{}}let t={workspacePath:e,workspaceName:o,python:await mt(),poetry:await gt(),pipx:await ft(),rapidkitCore:await ht(),projects:[]};try{let i=new Set([".git",".venv","node_modules",".rapidkit","dist","build","coverage","__pycache__"]),r=new Set;await Ne(e)&&r.add(e);let s=async(c,a)=>{if(a<0)return;let l=await yt(c);for(let d of l){if(i.has(d))continue;let m=w.join(c,d);if(await Ne(m)){r.add(m);continue}a>0&&await s(m,a-1);}};if(await s(e,1),a.debug(`Workspace scan (shallow) found ${r.size} project(s)`),r.size===0){let c=await yo(e,3,i);c.forEach(a=>r.add(a)),a.debug(`Workspace scan (deep fallback) found ${c.length} project(s)`);}r.size>0&&a.debug(`Workspace projects detected: ${Array.from(r).join(", ")}`);for(let c of r){let a=await ho(c);t.projects.push(a);}}catch(i){a.debug(`Failed to scan workspace projects: ${i}`);}let n=[t.python,t.poetry,t.pipx,t.rapidkitCore];if(t.healthScore=ko(n,t.projects),t.rapidkitCore.status==="ok"){let i=t.rapidkitCore.message.match(/([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);i&&(t.coreVersion=i[1]);}return t}function q(e,o){let t=e.status==="ok"?"\u2705":e.status==="warn"?"\u26A0\uFE0F":"\u274C",n=e.status==="ok"?u.green:e.status==="warn"?u.yellow:u.red;console.log(`${t} ${u.bold(o)}: ${n(e.message)}`),e.paths&&e.paths.length>0?e.paths.forEach(i=>{let r=i.version?u.cyan(` -> ${i.version}`):"";console.log(` ${u.cyan("\u2022")} ${u.gray(i.location)}: ${u.dim(i.path)}${r}`);}):e.details&&console.log(` ${u.gray(e.details)}`);}function bo(e){let o=e.issues.length>0,t=o?"\u26A0\uFE0F":"\u2705",n=o?u.yellow:u.green;if(console.log(`
855
+ `);}catch(s){throw r.fail(`Failed to generate ${i} project`),s}}async function mt(){let e=process.platform==="win32"?["python","python3"]:["python3","python"];for(let o of e)try{let{stdout:t}=await execa(o,["--version"],{timeout:3e3}),n=t.match(/Python (\d+\.\d+\.\d+)/);if(n){let i=n[1],[r,s]=i.split(".").map(Number);return r<3||r===3&&s<10?{status:"warn",message:`Python ${i} (requires 3.10+)`,details:`${o} found but version is below minimum requirement`}:{status:"ok",message:`Python ${i}`,details:`Using ${o}`}}}catch{continue}return {status:"error",message:"Python not found",details:"Install Python 3.10+ and ensure it's in PATH"}}async function gt(){try{let{stdout:e}=await execa("poetry",["--version"],{timeout:3e3}),o=e.match(/Poetry .*version ([\d.]+)/);return o?{status:"ok",message:`Poetry ${o[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 ft(){try{let{stdout:e}=await execa("pipx",["--version"],{timeout:3e3});return {status:"ok",message:`pipx ${e.trim()}`,details:"Available for global tool installation"}}catch{return {status:"warn",message:"pipx not installed",details:"Optional: Install for isolated Python tools"}}}async function ht(){let e=process.env.HOME||process.env.USERPROFILE||"",o=[],t=[{location:"Global (pipx)",path:w.join(e,".local","bin","rapidkit")},{location:"Global (pipx)",path:w.join(e,"AppData","Roaming","Python","Scripts","rapidkit.exe")},{location:"Global (pyenv)",path:w.join(e,".pyenv","shims","rapidkit")},{location:"Global (system)",path:"/usr/local/bin/rapidkit"},{location:"Global (system)",path:"/usr/bin/rapidkit"}],n=[{location:"Workspace (.venv)",path:w.join(process.cwd(),".venv","bin","rapidkit")},{location:"Workspace (.venv)",path:w.join(process.cwd(),".venv","Scripts","rapidkit.exe")}];for(let{location:r,path:s}of [...t,...n])try{if(await k__default.pathExists(s)){let{stdout:c,exitCode:a}=await execa(s,["--version"],{timeout:3e3,reject:false});if(a===0&&(c.includes("RapidKit Version")||c.includes("RapidKit"))){let l=c.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);l&&o.push({location:r,path:s,version:l[1]});}}}catch{continue}if(o.length>0)return {status:"ok",message:`RapidKit Core ${o[0].version}`,paths:o.map(s=>({location:s.location,path:s.path,version:s.version}))};try{let{stdout:r,exitCode:s}=await execa("rapidkit",["--version"],{timeout:3e3,reject:false});if(s===0&&(r.includes("RapidKit Version")||r.includes("RapidKit"))){let c=r.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(c)return {status:"ok",message:`RapidKit Core ${c[1]}`,details:"Available via PATH"}}}catch{}try{let{stdout:r,exitCode:s}=await execa("poetry",["run","rapidkit","--version"],{timeout:3e3,reject:false});if(s===0&&(r.includes("RapidKit Version")||r.includes("RapidKit"))){let c=r.match(/v?([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);if(c)return {status:"ok",message:`RapidKit Core ${c[1]}`,details:"Available via Poetry"}}}catch{}let i=process.platform==="win32"?["python","python3"]:["python3","python"];for(let r of i)try{let{stdout:s,exitCode:c}=await execa(r,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:3e3,reject:false});if(c===0&&s&&!s.includes("Traceback")&&!s.includes("ModuleNotFoundError")){let a=s.trim();if(a)return {status:"ok",message:`RapidKit Core ${a}`,details:`Available in ${r} environment`}}}catch{continue}return {status:"error",message:"RapidKit Core not installed",details:"Install with: pipx install rapidkit-core"}}async function Te(e,o){let t=w.join(e,"Dockerfile");o.hasDocker=await k__default.pathExists(t);let n=w.join(e,"tests"),i=w.join(e,"test");if(o.hasTests=await k__default.pathExists(n)||await k__default.pathExists(i),o.framework==="NestJS"){let r=w.join(e,".eslintrc.js"),s=w.join(e,".eslintrc.json");o.hasCodeQuality=await k__default.pathExists(r)||await k__default.pathExists(s);}else if(o.framework==="FastAPI"){let r=w.join(e,"ruff.toml"),s=w.join(e,"pyproject.toml");if(await k__default.pathExists(s))try{let c=await k__default.readFile(s,"utf8");o.hasCodeQuality=c.includes("[tool.ruff]")||await k__default.pathExists(r);}catch{o.hasCodeQuality=await k__default.pathExists(r);}}try{if(o.framework==="NestJS"){let{stdout:r}=await execa("npm",["audit","--json"],{cwd:e,reject:false});if(r)try{let c=JSON.parse(r).metadata?.vulnerabilities;c&&(o.vulnerabilities=(c.high||0)+(c.critical||0)+(c.moderate||0));}catch{}}else if(o.framework==="FastAPI"){let r=w.join(e,".venv"),s=process.platform==="win32"?w.join(r,"Scripts","python.exe"):w.join(r,"bin","python");if(await k__default.pathExists(s))try{let{stdout:c}=await execa(s,["-m","pip","list","--format=json"],{timeout:5e3,reject:false});if(c){JSON.parse(c);o.vulnerabilities=0;}}catch{}}}catch{}}async function yo(e){let t={name:w.basename(e),path:e,venvActive:false,depsInstalled:false,coreInstalled:false,issues:[],fixCommands:[]},n=w.join(e,".rapidkit");if(!await k__default.pathExists(n))return t.issues.push("Not a valid RapidKit project (missing .rapidkit directory)"),t;try{let a=w.join(e,"registry.json");if(await k__default.pathExists(a)){let l=await k__default.readJson(a);l.installed_modules&&(t.stats={modules:l.installed_modules.length});}}catch{}try{let a=w.join(n,"project.json");if(await k__default.pathExists(a)){let l=await k__default.readJson(a);l.kit&&(t.kit=l.kit);}}catch{}try{let a=w.join(e,".git");if(await k__default.pathExists(a)){let{stdout:l}=await execa("git",["log","-1","--format=%cr"],{cwd:e,reject:false});l&&(t.lastModified=l.trim());}else {let l=await k__default.stat(e),m=Date.now()-l.mtime.getTime(),p=Math.floor(m/(1e3*60*60*24));t.lastModified=p===0?"today":`${p} day${p>1?"s":""} ago`;}}catch{}let i=w.join(e,"package.json"),r=w.join(e,"pyproject.toml"),s=await k__default.pathExists(i),c=await k__default.pathExists(r);if(s){t.framework="NestJS",t.venvActive=true;let a=w.join(e,"node_modules");if(await k__default.pathExists(a))try{let p=(await k__default.readdir(a)).filter(y=>!y.startsWith(".")&&!y.startsWith("_"));t.depsInstalled=p.length>0;}catch{t.depsInstalled=false;}t.depsInstalled||(t.issues.push("Dependencies not installed (node_modules empty or missing)"),t.fixCommands?.push(`cd ${e} && rapidkit init`)),t.coreInstalled=false;let l=w.join(e,".env");if(t.hasEnvFile=await k__default.pathExists(l),!t.hasEnvFile){let m=w.join(e,".env.example");await k__default.pathExists(m)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(`cd ${e} && cp .env.example .env`));}let d=w.join(e,"src");if(t.modulesHealthy=true,t.missingModules=[],await k__default.pathExists(d))try{let m=await k__default.readdir(d);t.modulesHealthy=m.length>0;}catch{t.modulesHealthy=false;}return await Te(e,t),t}if(c){t.framework="FastAPI";let a=w.join(e,".venv");if(await k__default.pathExists(a)){t.venvActive=true;let p=process.platform==="win32"?w.join(a,"Scripts","python.exe"):w.join(a,"bin","python");if(await k__default.pathExists(p)){try{let{stdout:y}=await execa(p,["-c","import rapidkit_core; print(rapidkit_core.__version__)"],{timeout:2e3});t.coreInstalled=true,t.coreVersion=y.trim();}catch{t.coreInstalled=false;}try{await execa(p,["-c","import fastapi"],{timeout:2e3}),t.depsInstalled=true;}catch{try{let y=w.join(a,"lib");if(await k__default.pathExists(y)){let v=(await k__default.readdir(y)).find(C=>C.startsWith("python"));if(v){let C=w.join(y,v,"site-packages");if(await k__default.pathExists(C)){let M=(await k__default.readdir(C)).filter(U=>!U.startsWith("_")&&!U.includes("dist-info")&&!["pip","setuptools","wheel","pkg_resources"].includes(U));t.depsInstalled=M.length>0;}}}t.depsInstalled||(t.issues.push("Dependencies not installed"),t.fixCommands?.push(`cd ${e} && rapidkit init`));}catch{t.issues.push("Could not verify dependency installation");}}}else t.issues.push("Virtual environment exists but Python executable not found");}else t.issues.push("Virtual environment not created"),t.fixCommands?.push(`cd ${e} && rapidkit init`);let l=w.join(e,".env");if(t.hasEnvFile=await k__default.pathExists(l),!t.hasEnvFile){let p=w.join(e,".env.example");await k__default.pathExists(p)&&(t.issues.push("Environment file missing (found .env.example)"),t.fixCommands?.push(`cd ${e} && cp .env.example .env`));}let d=w.join(e,"src"),m=w.join(e,"modules");if(t.modulesHealthy=true,t.missingModules=[],await k__default.pathExists(d)){let p=w.join(d,"__init__.py");await k__default.pathExists(p)||(t.modulesHealthy=false,t.missingModules.push("src/__init__.py"));}if(await k__default.pathExists(m))try{let p=await yt(m);for(let y of p){let P=w.join(m,y,"__init__.py");await k__default.pathExists(P)||(t.modulesHealthy=false,t.missingModules.push(`modules/${y}/__init__.py`));}}catch{}return !t.modulesHealthy&&t.missingModules.length>0&&t.issues.push(`Missing module init files: ${t.missingModules.join(", ")}`),await Te(e,t),t}return t.issues.push("Unknown project type (no package.json or pyproject.toml)"),await Te(e,t),t}async function yt(e){try{return (await k__default.readdir(e,{withFileTypes:true})).filter(t=>t.isDirectory()).map(t=>t.name)}catch{try{let o=await k__default.readdir(e),t=[];for(let n of o)try{(await k__default.stat(w.join(e,n))).isDirectory()&&t.push(n);}catch{continue}return t}catch{return []}}}async function Ne(e){let o=w.join(e,".rapidkit");if(!await k__default.pathExists(o))return false;let t=["project.json","context.json","file-hashes.json"];for(let n of t)if(await k__default.pathExists(w.join(o,n)))return true;return false}function wt(e,o){if(o.has(e))return true;let t=e.toLowerCase();return !!(t==="dist"||t.startsWith("dist-")||t.startsWith("dist_")||t==="build"||t.startsWith("build-")||t.startsWith("build_"))}async function wo(e,o,t){let n=new Set,i=[{dir:e,depth:0}];for(;i.length>0;){let r=i.shift();if(!r)break;try{let s=await k__default.readdir(r.dir);for(let c of s){if(wt(c,t))continue;let a=w.join(r.dir,c),l;try{l=await k__default.stat(a);}catch{continue}if(l.isDirectory()){if(await Ne(a)){n.add(a);continue}r.depth<o&&i.push({dir:a,depth:r.depth+1});}}}catch{continue}}return Array.from(n)}async function ko(e){let o=e,t=w.parse(o).root;for(;o!==t;){let n=[w.join(o,".rapidkit-workspace"),w.join(o,".rapidkit","workspace-marker.json"),w.join(o,".rapidkit","config.json")];for(let i of n)if(await k__default.pathExists(i))return o;o=w.dirname(o);}return null}function vo(e,o){let t=0,n=0,i=0;return e.forEach(s=>{s.status==="ok"?t++:s.status==="warn"?n++:s.status==="error"&&i++;}),o.forEach(s=>{s.issues.length===0&&s.venvActive&&s.depsInstalled?t++:s.issues.length>0&&n++;}),{total:t+n+i,passed:t,warnings:n,errors:i}}async function bo(e){let o=w.basename(e);try{let i=w.join(e,".rapidkit-workspace");await k__default.pathExists(i)&&(o=(await k__default.readJSON(i)).name||o);}catch{try{let i=w.join(e,".rapidkit","config.json");o=(await k__default.readJSON(i)).workspace_name||o;}catch{}}let t={workspacePath:e,workspaceName:o,python:await mt(),poetry:await gt(),pipx:await ft(),rapidkitCore:await ht(),projects:[]};try{let i=new Set([".git",".venv","node_modules",".rapidkit","dist","build","coverage","__pycache__"]),r=new Set;await Ne(e)&&r.add(e);let s=async(c,a)=>{if(a<0)return;let l=await yt(c);for(let d of l){if(wt(d,i))continue;let m=w.join(c,d);if(await Ne(m)){r.add(m);continue}a>0&&await s(m,a-1);}};if(await s(e,1),a.debug(`Workspace scan (shallow) found ${r.size} project(s)`),r.size===0){let c=await wo(e,3,i);c.forEach(a=>r.add(a)),a.debug(`Workspace scan (deep fallback) found ${c.length} project(s)`);}r.size>0&&a.debug(`Workspace projects detected: ${Array.from(r).join(", ")}`);for(let c of r){let a=await yo(c);t.projects.push(a);}}catch(i){a.debug(`Failed to scan workspace projects: ${i}`);}let n=[t.python,t.poetry,t.pipx,t.rapidkitCore];if(t.healthScore=vo(n,t.projects),t.rapidkitCore.status==="ok"){let i=t.rapidkitCore.message.match(/([\d.]+(?:rc\d+)?(?:a\d+)?(?:b\d+)?)/);i&&(t.coreVersion=i[1]);}return t}function q(e,o){let t=e.status==="ok"?"\u2705":e.status==="warn"?"\u26A0\uFE0F":"\u274C",n=e.status==="ok"?u.green:e.status==="warn"?u.yellow:u.red;console.log(`${t} ${u.bold(o)}: ${n(e.message)}`),e.paths&&e.paths.length>0?e.paths.forEach(i=>{let r=i.version?u.cyan(` -> ${i.version}`):"";console.log(` ${u.cyan("\u2022")} ${u.gray(i.location)}: ${u.dim(i.path)}${r}`);}):e.details&&console.log(` ${u.gray(e.details)}`);}function xo(e){let o=e.issues.length>0,t=o?"\u26A0\uFE0F":"\u2705",n=o?u.yellow:u.green;if(console.log(`
856
856
  ${t} ${u.bold("Project")}: ${n(e.name)}`),e.framework){let c=e.framework==="FastAPI"?"\u{1F40D}":e.framework==="NestJS"?"\u{1F985}":"\u{1F4E6}";console.log(` ${c} Framework: ${u.cyan(e.framework)}${e.kit?u.gray(` (${e.kit})`):""}`);}if(console.log(` ${u.gray(`Path: ${e.path}`)}`),!(e.venvActive&&!e.coreInstalled)&&(e.venvActive?console.log(` \u2705 Virtual environment: ${u.green("Active")}`):console.log(` \u274C Virtual environment: ${u.red("Not found")}`),e.coreInstalled?console.log(` ${u.dim("\u2139")} RapidKit Core: ${u.gray(e.coreVersion||"In venv")} ${u.dim("(optional)")}`):console.log(` ${u.dim("\u2139")} RapidKit Core: ${u.gray("Using global installation")} ${u.dim("(recommended)")}`)),e.depsInstalled?console.log(` \u2705 Dependencies: ${u.green("Installed")}`):console.log(` \u26A0\uFE0F Dependencies: ${u.yellow("Not installed")}`),e.hasEnvFile!==void 0&&(e.hasEnvFile?console.log(` \u2705 Environment: ${u.green(".env configured")}`):console.log(` \u26A0\uFE0F Environment: ${u.yellow(".env missing")}`)),e.modulesHealthy!==void 0&&(e.modulesHealthy?console.log(` \u2705 Modules: ${u.green("Healthy")}`):e.missingModules&&e.missingModules.length>0&&console.log(` \u26A0\uFE0F Modules: ${u.yellow(`Missing ${e.missingModules.length} init file(s)`)}`)),e.stats){let c=[];e.stats.modules!==void 0&&c.push(`${e.stats.modules} module${e.stats.modules!==1?"s":""}`),c.length>0&&console.log(` \u{1F4CA} Stats: ${u.cyan(c.join(" \u2022 "))}`);}e.lastModified&&console.log(` \u{1F552} Last Modified: ${u.gray(e.lastModified)}`);let s=[];if(e.hasTests!==void 0&&s.push(e.hasTests?"\u2705 Tests":u.dim("\u2298 No tests")),e.hasDocker!==void 0&&s.push(e.hasDocker?"\u2705 Docker":u.dim("\u2298 No Docker")),e.hasCodeQuality!==void 0){let c=e.framework==="NestJS"?"ESLint":"Ruff";s.push(e.hasCodeQuality?`\u2705 ${c}`:u.dim(`\u2298 No ${c}`));}s.length>0&&console.log(` ${s.join(" \u2022 ")}`),e.vulnerabilities!==void 0&&e.vulnerabilities>0&&console.log(` \u26A0\uFE0F Security: ${u.yellow(`${e.vulnerabilities} vulnerability(ies) found`)}`),e.issues.length>0&&(console.log(` ${u.bold("Issues:")}`),e.issues.forEach(c=>{console.log(` \u2022 ${u.yellow(c)}`);}),e.fixCommands&&e.fixCommands.length>0&&(console.log(`
857
857
  ${u.bold.cyan("\u{1F527} Quick Fix:")}`),e.fixCommands.forEach(c=>{console.log(` ${u.cyan("$")} ${u.white(c)}`);})));}async function ut(e,o=false){let t=e.filter(i=>i.fixCommands&&i.fixCommands.length>0);if(t.length===0){console.log(u.green(`
858
858
  \u2705 No fixes needed - all projects are healthy!`));return}console.log(u.bold.cyan(`
@@ -863,15 +863,15 @@ ${t} ${u.bold("Project")}: ${n(e.name)}`),e.framework){let c=e.framework==="Fast
863
863
  `));for(let i of t){console.log(u.bold(`Fixing ${u.cyan(i.name)}...`));for(let r of i.fixCommands)try{console.log(u.gray(` $ ${r}`)),await execa(r,{shell:true,stdio:"inherit"}),console.log(u.green(` \u2705 Success
864
864
  `));}catch(s){console.log(u.red(` \u274C Failed: ${s instanceof Error?s.message:String(s)}
865
865
  `));}}console.log(u.bold.green(`
866
- \u2705 Fix process completed!`));}async function wt(e={}){if(e.json||console.log(u.bold.cyan(`
866
+ \u2705 Fix process completed!`));}async function kt(e={}){if(e.json||console.log(u.bold.cyan(`
867
867
  \u{1FA7A} RapidKit Health Check
868
- `)),e.workspace){let o=await wo(process.cwd());o||(a.error("No RapidKit workspace found in current directory or parents"),a.info('Run this command from within a workspace, or use "rapidkit doctor" for system check'),process.exit(1)),e.json||(console.log(u.bold(`Workspace: ${u.cyan(w.basename(o))}`)),console.log(u.gray(`Path: ${o}`)));let t=await vo(o);if(e.json){let r={workspace:{name:w.basename(o),path:o},healthScore:t.healthScore,system:{python:t.python,poetry:t.poetry,pipx:t.pipx,rapidkitCore:t.rapidkitCore,versions:{core:t.coreVersion,npm:t.npmVersion}},projects:t.projects.map(s=>({name:s.name,path:s.path,venvActive:s.venvActive,depsInstalled:s.depsInstalled,coreInstalled:s.coreInstalled,coreVersion:s.coreVersion,issues:s.issues,fixCommands:s.fixCommands})),summary:{totalProjects:t.projects.length,totalIssues:t.projects.reduce((s,c)=>s+c.issues.length,0),hasSystemErrors:[t.python,t.rapidkitCore].some(s=>s.status==="error")}};console.log(JSON.stringify(r,null,2));return}if(t.healthScore){let r=t.healthScore,s=Math.round(r.passed/r.total*100),c=s>=80?u.green:s>=50?u.yellow:u.red,a="\u2588".repeat(Math.floor(s/5))+"\u2591".repeat(20-Math.floor(s/5));console.log(u.bold(`
868
+ `)),e.workspace){let o=await ko(process.cwd());o||(a.error("No RapidKit workspace found in current directory or parents"),a.info('Run this command from within a workspace, or use "rapidkit doctor" for system check'),process.exit(1)),e.json||(console.log(u.bold(`Workspace: ${u.cyan(w.basename(o))}`)),console.log(u.gray(`Path: ${o}`)));let t=await bo(o);if(e.json){let r={workspace:{name:w.basename(o),path:o},healthScore:t.healthScore,system:{python:t.python,poetry:t.poetry,pipx:t.pipx,rapidkitCore:t.rapidkitCore,versions:{core:t.coreVersion,npm:t.npmVersion}},projects:t.projects.map(s=>({name:s.name,path:s.path,venvActive:s.venvActive,depsInstalled:s.depsInstalled,coreInstalled:s.coreInstalled,coreVersion:s.coreVersion,issues:s.issues,fixCommands:s.fixCommands})),summary:{totalProjects:t.projects.length,totalIssues:t.projects.reduce((s,c)=>s+c.issues.length,0),hasSystemErrors:[t.python,t.rapidkitCore].some(s=>s.status==="error")}};console.log(JSON.stringify(r,null,2));return}if(t.healthScore){let r=t.healthScore,s=Math.round(r.passed/r.total*100),c=s>=80?u.green:s>=50?u.yellow:u.red,a="\u2588".repeat(Math.floor(s/5))+"\u2591".repeat(20-Math.floor(s/5));console.log(u.bold(`
869
869
  \u{1F4CA} Health Score:`)),console.log(` ${c(`${s}%`)} ${u.gray(a)}`),console.log(` ${u.green(`\u2705 ${r.passed} passed`)} ${u.gray("|")} ${u.yellow(`\u26A0\uFE0F ${r.warnings} warnings`)} ${u.gray("|")} ${u.red(`\u274C ${r.errors} errors`)}`);}if(console.log(u.bold(`
870
870
 
871
871
  System Tools:
872
872
  `)),q(t.python,"Python"),q(t.poetry,"Poetry"),q(t.pipx,"pipx"),q(t.rapidkitCore,"RapidKit Core"),t.coreVersion&&t.npmVersion){let r=t.coreVersion.split(".")[1],s=t.npmVersion.split(".")[1];r!==s&&(console.log(u.yellow(`
873
873
  \u26A0\uFE0F Version mismatch: Core ${t.coreVersion} / CLI ${t.npmVersion}`)),console.log(u.gray(" Consider updating to matching versions for best compatibility")));}t.projects.length>0?(console.log(u.bold(`
874
- \u{1F4E6} Projects (${t.projects.length}):`)),t.projects.forEach(r=>bo(r))):(console.log(u.bold(`
874
+ \u{1F4E6} Projects (${t.projects.length}):`)),t.projects.forEach(r=>xo(r))):(console.log(u.bold(`
875
875
  \u{1F4E6} Projects:`)),console.log(u.gray(" No RapidKit projects found in workspace")));let n=t.projects.reduce((r,s)=>r+s.issues.length,0),i=[t.python,t.rapidkitCore].some(r=>r.status==="error");i||n>0?(console.log(u.bold.yellow(`
876
876
  \u26A0\uFE0F Found ${n} project issue(s)`)),i&&console.log(u.bold.red("\u274C System requirements not met")),e.fix?await ut(t.projects,true):n>0&&await ut(t.projects,false)):console.log(u.bold.green(`
877
877
  \u2705 All checks passed! Workspace is healthy.`));}else {console.log(u.bold(`System Tools:
@@ -879,9 +879,9 @@ System Tools:
879
879
  \u274C Some required tools are missing`)),console.log(u.gray(`
880
880
  Tip: Run "rapidkit doctor --workspace" from within a workspace for detailed project checks`))):(console.log(u.bold.green(`
881
881
  \u2705 All required tools are installed!`)),console.log(u.gray(`
882
- Tip: Run "rapidkit doctor --workspace" from within a workspace for detailed project checks`)));}console.log("");}var We=w.join(Jt__default.homedir(),".rapidkit"),xe=w.join(We,"config.json");function oe(){try{if(!S.existsSync(xe))return {};let e=S.readFileSync(xe,"utf-8");return JSON.parse(e)}catch{return {}}}function Pe(e){let t={...oe(),...e};S.existsSync(We)||S.mkdirSync(We,{recursive:true}),S.writeFileSync(xe,JSON.stringify(t,null,2),"utf-8");}function le(){return process.env.OPENAI_API_KEY||oe().openaiApiKey||null}function Le(){return oe().aiEnabled!==false}function Ge(){return xe}async function vt(){return (await import('inquirer')).default}function bt(e){let o=e.command("config").description("Configure RapidKit settings");o.command("set-api-key").description("Set OpenAI API key for AI features").option("--key <key>","API key (or enter interactively)").action(async t=>{let n=t.key;n?n.startsWith("sk-")||(console.log(u.red(`
882
+ Tip: Run "rapidkit doctor --workspace" from within a workspace for detailed project checks`)));}console.log("");}var We=w.join(zt__default.homedir(),".rapidkit"),xe=w.join(We,"config.json");function oe(){try{if(!S.existsSync(xe))return {};let e=S.readFileSync(xe,"utf-8");return JSON.parse(e)}catch{return {}}}function Pe(e){let t={...oe(),...e};S.existsSync(We)||S.mkdirSync(We,{recursive:true}),S.writeFileSync(xe,JSON.stringify(t,null,2),"utf-8");}function le(){return process.env.OPENAI_API_KEY||oe().openaiApiKey||null}function Le(){return oe().aiEnabled!==false}function Ge(){return xe}async function bt(){return (await import('inquirer')).default}function xt(e){let o=e.command("config").description("Configure RapidKit settings");o.command("set-api-key").description("Set OpenAI API key for AI features").option("--key <key>","API key (or enter interactively)").action(async t=>{let n=t.key;n?n.startsWith("sk-")||(console.log(u.red(`
883
883
  \u274C Invalid API key format (should start with sk-)
884
- `)),process.exit(1)):n=(await(await vt()).prompt([{type:"password",name:"apiKey",message:"Enter your OpenAI API key:",validate:s=>s?s.startsWith("sk-")?s.length<20?"API key seems too short":true:"Invalid API key format (should start with sk-)":"API key is required"}])).apiKey,Pe({openaiApiKey:n}),console.log(u.green(`
884
+ `)),process.exit(1)):n=(await(await bt()).prompt([{type:"password",name:"apiKey",message:"Enter your OpenAI API key:",validate:s=>s?s.startsWith("sk-")?s.length<20?"API key seems too short":true:"Invalid API key format (should start with sk-)":"API key is required"}])).apiKey,Pe({openaiApiKey:n}),console.log(u.green(`
885
885
  \u2705 OpenAI API key saved successfully!
886
886
  `)),console.log(u.gray(`Stored in: ${Ge()}`)),console.log(u.cyan(`
887
887
  \u{1F389} You can now use AI features:`)),console.log(u.white(' rapidkit ai recommend "I need user authentication"')),console.log(u.gray(`
@@ -892,7 +892,7 @@ Tip: Run "rapidkit doctor --workspace" from within a workspace for detailed proj
892
892
  \u{1F4C1} Config file: ${Ge()}
893
893
  `));}),o.command("remove-api-key").description("Remove stored OpenAI API key").action(async()=>{if(!oe().openaiApiKey){console.log(u.yellow(`
894
894
  \u26A0\uFE0F No API key is currently stored
895
- `));return}(await(await vt()).prompt([{type:"confirm",name:"confirm",message:"Are you sure you want to remove your OpenAI API key?",default:false}])).confirm?(Pe({openaiApiKey:void 0}),console.log(u.green(`
895
+ `));return}(await(await bt()).prompt([{type:"confirm",name:"confirm",message:"Are you sure you want to remove your OpenAI API key?",default:false}])).confirm?(Pe({openaiApiKey:void 0}),console.log(u.green(`
896
896
  \u2705 API key removed successfully
897
897
  `))):console.log(u.gray(`
898
898
  Cancelled
@@ -900,15 +900,15 @@ Cancelled
900
900
  \u274C Invalid action: ${t}`)),console.log(u.gray(`Use: rapidkit config ai enable|disable
901
901
  `)),process.exit(1));let n=t==="enable";Pe({aiEnabled:n}),console.log(u.green(`
902
902
  \u2705 AI features ${n?"enabled":"disabled"}
903
- `));});}var je=null,Ie=false,Ve=null;async function Po(){return Ve||(Ve=(await import('openai')).default),Ve}function xt(){Ie=true;}function Pt(e){let t=new Array(1536),n=0;for(let r=0;r<e.length;r++)n=(n<<5)-n+e.charCodeAt(r),n=n&n;for(let r=0;r<1536;r++)n=n*1664525+1013904223&4294967295,t[r]=n/4294967295*2-1;let i=Math.sqrt(t.reduce((r,s)=>r+s*s,0));return t.map(r=>r/i)}async function Ce(e){let o=await Po();je=new o({apiKey:e});}function jt(){if(!je)throw new Error("OpenAI client not initialized. Call initOpenAI() first with your API key.");return je}async function It(e){return Ie?Pt(e):(await jt().embeddings.create({model:"text-embedding-3-small",input:e,encoding_format:"float"})).data[0].embedding}async function Ct(e){return Ie?e.map(Pt):(await jt().embeddings.create({model:"text-embedding-3-small",input:e,encoding_format:"float"})).data.map(n=>n.embedding)}function Rt(){return je!==null}function $t(){return Ie}var Co=promisify(exec),Et=[{id:"authentication-core",name:"Authentication Core",category:"auth",description:"Complete authentication system with password hashing, JWT tokens, OAuth 2.0, and secure session management",longDescription:"Production-ready authentication with bcrypt password hashing, JWT access/refresh tokens, OAuth 2.0 providers (Google, GitHub, etc), rate limiting, and security best practices.",keywords:["auth","login","password","jwt","oauth","token","authentication","security","signin","signup"],framework:"both",dependencies:[],useCases:["User login and logout","Password reset flow","OAuth social login (Google, GitHub)","JWT authentication","Secure session management","Token refresh","Rate limiting"]},{id:"users-core",name:"Users Core",category:"auth",description:"User management system with profiles, roles, permissions, and user CRUD operations",longDescription:"Complete user management with user profiles, role-based access control (RBAC), permissions, user search, soft delete, and audit trails.",keywords:["user","profile","role","permission","rbac","management","admin","accounts"],framework:"both",dependencies:["authentication-core"],useCases:["User registration","User profile management","Role management (admin, user, etc)","Permission system","User administration dashboard","Soft delete users"]},{id:"session-management",name:"Session Management",category:"auth",description:"Secure session handling with Redis storage, session rotation, and device tracking",longDescription:"Advanced session management with Redis-backed storage, automatic session rotation, device fingerprinting, IP tracking, and session revocation.",keywords:["session","redis","cookie","storage","device","tracking"],framework:"both",dependencies:["authentication-core","redis-cache"],useCases:["User session management","Remember me functionality","Device tracking","Session security","Logout from all devices","Session expiration"]},{id:"db-postgres",name:"PostgreSQL",category:"database",description:"PostgreSQL integration with async SQLAlchemy, migrations, connection pooling, and query optimization",longDescription:"Production-ready PostgreSQL with async SQLAlchemy 2.0, Alembic migrations, connection pooling, query optimization, JSON support, and full-text search.",keywords:["postgres","postgresql","database","sql","sqlalchemy","migration","orm","relational"],framework:"both",dependencies:[],useCases:["Relational database","Complex SQL queries","Database transactions","Data integrity","Production-grade database","ACID compliance"]},{id:"db-mongodb",name:"MongoDB",category:"database",description:"MongoDB integration with Motor async driver, schema validation, and aggregation pipelines",longDescription:"Async MongoDB with Motor driver, Pydantic schema validation, aggregation pipelines, indexes, and Atlas integration.",keywords:["mongodb","mongo","nosql","document","database","motor"],framework:"both",dependencies:[],useCases:["Document storage","Flexible schema","Real-time data","JSON documents","Unstructured data","Analytics"]},{id:"stripe-payment",name:"Stripe Payment",category:"payment",description:"Stripe integration with payment intents, subscriptions, webhooks, and customer portal",longDescription:"Complete Stripe integration with Payment Intents API, subscription management, automatic webhooks, customer portal, refunds, and SCA compliance.",keywords:["stripe","payment","subscription","billing","checkout","webhook","credit card"],framework:"both",dependencies:[],useCases:["Accept credit card payments","Subscription billing","One-time payments","Checkout flow","Payment webhooks","Refunds and disputes"]},{id:"email",name:"Email",category:"communication",description:"Email sending with templates, SMTP/SendGrid/AWS SES support, and queue management",longDescription:"Production email system with Jinja2 templates, multiple providers (SMTP, SendGrid, AWS SES), queue management, retry logic, and bounce handling.",keywords:["email","mail","smtp","sendgrid","ses","template","notification"],framework:"both",dependencies:[],useCases:["Welcome emails","Password reset emails","Notifications","Marketing emails","Transactional emails","Email templates"]},{id:"sms",name:"SMS",category:"communication",description:"SMS sending with Twilio, verification codes, and delivery tracking",longDescription:"SMS integration with Twilio, verification codes, two-factor authentication, delivery tracking, and international support.",keywords:["sms","twilio","text","message","2fa","verification","otp"],framework:"both",dependencies:[],useCases:["2FA verification codes","SMS notifications","Phone verification","OTP generation","SMS alerts"]},{id:"redis-cache",name:"Redis Cache",category:"infrastructure",description:"Redis caching with decorators, TTL management, and cache invalidation patterns",longDescription:"Redis integration with async client, caching decorators, TTL management, cache invalidation, pub/sub, and rate limiting.",keywords:["redis","cache","memory","performance","speed","pubsub"],framework:"both",dependencies:[],useCases:["API response caching","Session storage","Rate limiting","Real-time features","Performance optimization","Pub/sub messaging"]},{id:"celery",name:"Celery",category:"infrastructure",description:"Background task processing with Celery, periodic tasks, and monitoring",longDescription:"Celery task queue with Redis/RabbitMQ backend, periodic tasks (cron), task monitoring, retry logic, and failure handling.",keywords:["celery","task","background","queue","async","worker","job","cron"],framework:"fastapi",dependencies:["redis-cache"],useCases:["Background email sending","Data processing","Report generation","Scheduled tasks","Long-running jobs"]},{id:"storage",name:"Storage",category:"infrastructure",description:"File storage with S3, local filesystem, and image processing",longDescription:"Unified storage interface for AWS S3, local files, image resizing, format conversion, CDN integration, and presigned URLs.",keywords:["storage","s3","file","upload","image","cdn","aws"],framework:"both",dependencies:[],useCases:["File uploads","Image storage","Document management","Profile pictures","Media files","CDN integration"]}],ne=null,At=0,Ro=300*1e3;function $o(e){return {id:e.name||e.id||e.module_id||"",name:e.display_name||e.name||"",category:Ao(e.category||"infrastructure"),description:e.description||e.summary||"",longDescription:e.long_description||e.description||"",keywords:e.keywords||e.tags||[],framework:Eo(e.framework),dependencies:e.dependencies||[],useCases:e.use_cases||e.useCases||[]}}function Ao(e){return {auth:"auth",authentication:"auth",database:"database",payment:"payment",billing:"payment",communication:"communication",infrastructure:"infrastructure",security:"security",analytics:"analytics"}[e.toLowerCase()]||"infrastructure"}function Eo(e){if(!e)return "both";if(typeof e=="string"){if(e.toLowerCase().includes("fastapi"))return "fastapi";if(e.toLowerCase().includes("nest"))return "nestjs"}return "both"}async function _o(){try{let{stdout:e}=await Co("rapidkit modules list --json-schema 1",{timeout:1e4,maxBuffer:10485760}),o=e.match(/\{[\s\S]*\}/),t=o?o[0]:e,n=JSON.parse(t),i=[];return Array.isArray(n)?i=n:n.modules&&Array.isArray(n.modules)?i=n.modules:n.data&&Array.isArray(n.data)&&(i=n.data),i.map($o).filter(r=>r.id&&r.name)}catch(e){return e.code==="ENOENT"?console.warn("\u26A0\uFE0F RapidKit Python Core not found in PATH"):e.killed?console.warn("\u26A0\uFE0F Python Core command timed out"):console.warn("\u26A0\uFE0F Failed to fetch modules from Python Core:",e.message),console.warn(" Using fallback module catalog (11 modules)"),Et}}async function Re(){let e=Date.now();return ne&&e-At<Ro||(ne=await _o(),At=e,ne.length===0&&(console.warn("\u26A0\uFE0F No modules found, using fallback catalog"),ne=Et)),ne}var Mo=fileURLToPath(import.meta.url),St=w.dirname(Mo),de=null;function Do(){if(de)return de;let e=[w.join(St,"../../data/modules-embeddings.json"),w.join(St,"../data/modules-embeddings.json"),w.join(process.cwd(),"data/modules-embeddings.json")],o=null;for(let i of e)if(S.existsSync(i)){o=i;break}if(!o)throw new Error("embeddings file not found");let t=S.readFileSync(o,"utf-8"),n=JSON.parse(t);return Array.isArray(n)?de={model:"mock-or-text-embedding-3-small",dimension:n[0]?.embedding?.length||1536,generated_at:new Date().toISOString(),modules:n}:de=n,de}function Ko(e,o){if(e.length!==o.length)throw new Error("Vectors must have the same length");let t=0,n=0,i=0;for(let s=0;s<e.length;s++)t+=e[s]*o[s],n+=e[s]*e[s],i+=o[s]*o[s];let r=Math.sqrt(n)*Math.sqrt(i);return r===0?0:t/r}function Fo(e,o){let t=o.toLowerCase(),n=e.keywords.filter(i=>t.includes(i)||i.includes(t));return n.length>0?`Matches: ${n.slice(0,3).join(", ")}`:`Relevant for: ${e.useCases[0]}`}async function Mt(e,o=5){let t=Do(),n=await Re(),i=await It(e),r=t.modules.map(s=>{let c=n.find(l=>l.id===s.id);if(!c)return null;let a=Ko(i,s.embedding);return {module:c,score:a,reason:Fo(c,e)}}).filter(s=>s!==null);return r.sort((s,c)=>c.score-s.score),r.slice(0,o)}var No=fileURLToPath(import.meta.url),Dt=w.dirname(No);async function Kt(){return (await import('inquirer')).default}function Wo(){return [w.join(Dt,"../../data/modules-embeddings.json"),w.join(Dt,"../data/modules-embeddings.json"),w.join(process.cwd(),"data/modules-embeddings.json")]}function Ft(){let e=Wo();for(let o of e)if(S.existsSync(o))try{let t=JSON.parse(S.readFileSync(o,"utf-8")),n=Array.isArray(t)?t:t.modules||[];return {exists:true,path:o,moduleCount:n.length,generatedAt:t.generated_at||null}}catch{continue}return {exists:false,path:null,moduleCount:0,generatedAt:null}}async function Ae(e=true,o){try{if(!Rt()&&!$t())return console.log(u.red(`
903
+ `));});}var je=null,Ie=false,Ve=null;async function jo(){return Ve||(Ve=(await import('openai')).default),Ve}function Pt(){Ie=true;}function jt(e){let t=new Array(1536),n=0;for(let r=0;r<e.length;r++)n=(n<<5)-n+e.charCodeAt(r),n=n&n;for(let r=0;r<1536;r++)n=n*1664525+1013904223&4294967295,t[r]=n/4294967295*2-1;let i=Math.sqrt(t.reduce((r,s)=>r+s*s,0));return t.map(r=>r/i)}async function Ce(e){let o=await jo();je=new o({apiKey:e});}function It(){if(!je)throw new Error("OpenAI client not initialized. Call initOpenAI() first with your API key.");return je}async function Ct(e){return Ie?jt(e):(await It().embeddings.create({model:"text-embedding-3-small",input:e,encoding_format:"float"})).data[0].embedding}async function Rt(e){return Ie?e.map(jt):(await It().embeddings.create({model:"text-embedding-3-small",input:e,encoding_format:"float"})).data.map(n=>n.embedding)}function $t(){return je!==null}function At(){return Ie}var Ro=promisify(exec),Et=[{id:"authentication-core",name:"Authentication Core",category:"auth",description:"Complete authentication system with password hashing, JWT tokens, OAuth 2.0, and secure session management",longDescription:"Production-ready authentication with bcrypt password hashing, JWT access/refresh tokens, OAuth 2.0 providers (Google, GitHub, etc), rate limiting, and security best practices.",keywords:["auth","login","password","jwt","oauth","token","authentication","security","signin","signup"],framework:"both",dependencies:[],useCases:["User login and logout","Password reset flow","OAuth social login (Google, GitHub)","JWT authentication","Secure session management","Token refresh","Rate limiting"]},{id:"users-core",name:"Users Core",category:"auth",description:"User management system with profiles, roles, permissions, and user CRUD operations",longDescription:"Complete user management with user profiles, role-based access control (RBAC), permissions, user search, soft delete, and audit trails.",keywords:["user","profile","role","permission","rbac","management","admin","accounts"],framework:"both",dependencies:["authentication-core"],useCases:["User registration","User profile management","Role management (admin, user, etc)","Permission system","User administration dashboard","Soft delete users"]},{id:"session-management",name:"Session Management",category:"auth",description:"Secure session handling with Redis storage, session rotation, and device tracking",longDescription:"Advanced session management with Redis-backed storage, automatic session rotation, device fingerprinting, IP tracking, and session revocation.",keywords:["session","redis","cookie","storage","device","tracking"],framework:"both",dependencies:["authentication-core","redis-cache"],useCases:["User session management","Remember me functionality","Device tracking","Session security","Logout from all devices","Session expiration"]},{id:"db-postgres",name:"PostgreSQL",category:"database",description:"PostgreSQL integration with async SQLAlchemy, migrations, connection pooling, and query optimization",longDescription:"Production-ready PostgreSQL with async SQLAlchemy 2.0, Alembic migrations, connection pooling, query optimization, JSON support, and full-text search.",keywords:["postgres","postgresql","database","sql","sqlalchemy","migration","orm","relational"],framework:"both",dependencies:[],useCases:["Relational database","Complex SQL queries","Database transactions","Data integrity","Production-grade database","ACID compliance"]},{id:"db-mongodb",name:"MongoDB",category:"database",description:"MongoDB integration with Motor async driver, schema validation, and aggregation pipelines",longDescription:"Async MongoDB with Motor driver, Pydantic schema validation, aggregation pipelines, indexes, and Atlas integration.",keywords:["mongodb","mongo","nosql","document","database","motor"],framework:"both",dependencies:[],useCases:["Document storage","Flexible schema","Real-time data","JSON documents","Unstructured data","Analytics"]},{id:"stripe-payment",name:"Stripe Payment",category:"payment",description:"Stripe integration with payment intents, subscriptions, webhooks, and customer portal",longDescription:"Complete Stripe integration with Payment Intents API, subscription management, automatic webhooks, customer portal, refunds, and SCA compliance.",keywords:["stripe","payment","subscription","billing","checkout","webhook","credit card"],framework:"both",dependencies:[],useCases:["Accept credit card payments","Subscription billing","One-time payments","Checkout flow","Payment webhooks","Refunds and disputes"]},{id:"email",name:"Email",category:"communication",description:"Email sending with templates, SMTP/SendGrid/AWS SES support, and queue management",longDescription:"Production email system with Jinja2 templates, multiple providers (SMTP, SendGrid, AWS SES), queue management, retry logic, and bounce handling.",keywords:["email","mail","smtp","sendgrid","ses","template","notification"],framework:"both",dependencies:[],useCases:["Welcome emails","Password reset emails","Notifications","Marketing emails","Transactional emails","Email templates"]},{id:"sms",name:"SMS",category:"communication",description:"SMS sending with Twilio, verification codes, and delivery tracking",longDescription:"SMS integration with Twilio, verification codes, two-factor authentication, delivery tracking, and international support.",keywords:["sms","twilio","text","message","2fa","verification","otp"],framework:"both",dependencies:[],useCases:["2FA verification codes","SMS notifications","Phone verification","OTP generation","SMS alerts"]},{id:"redis-cache",name:"Redis Cache",category:"infrastructure",description:"Redis caching with decorators, TTL management, and cache invalidation patterns",longDescription:"Redis integration with async client, caching decorators, TTL management, cache invalidation, pub/sub, and rate limiting.",keywords:["redis","cache","memory","performance","speed","pubsub"],framework:"both",dependencies:[],useCases:["API response caching","Session storage","Rate limiting","Real-time features","Performance optimization","Pub/sub messaging"]},{id:"celery",name:"Celery",category:"infrastructure",description:"Background task processing with Celery, periodic tasks, and monitoring",longDescription:"Celery task queue with Redis/RabbitMQ backend, periodic tasks (cron), task monitoring, retry logic, and failure handling.",keywords:["celery","task","background","queue","async","worker","job","cron"],framework:"fastapi",dependencies:["redis-cache"],useCases:["Background email sending","Data processing","Report generation","Scheduled tasks","Long-running jobs"]},{id:"storage",name:"Storage",category:"infrastructure",description:"File storage with S3, local filesystem, and image processing",longDescription:"Unified storage interface for AWS S3, local files, image resizing, format conversion, CDN integration, and presigned URLs.",keywords:["storage","s3","file","upload","image","cdn","aws"],framework:"both",dependencies:[],useCases:["File uploads","Image storage","Document management","Profile pictures","Media files","CDN integration"]}],ne=null,_t=0,$o=300*1e3;function Ao(e){return {id:e.name||e.id||e.module_id||"",name:e.display_name||e.name||"",category:_o(e.category||"infrastructure"),description:e.description||e.summary||"",longDescription:e.long_description||e.description||"",keywords:e.keywords||e.tags||[],framework:Eo(e.framework),dependencies:e.dependencies||[],useCases:e.use_cases||e.useCases||[]}}function _o(e){return {auth:"auth",authentication:"auth",database:"database",payment:"payment",billing:"payment",communication:"communication",infrastructure:"infrastructure",security:"security",analytics:"analytics"}[e.toLowerCase()]||"infrastructure"}function Eo(e){if(!e)return "both";if(typeof e=="string"){if(e.toLowerCase().includes("fastapi"))return "fastapi";if(e.toLowerCase().includes("nest"))return "nestjs"}return "both"}async function So(){try{let{stdout:e}=await Ro("rapidkit modules list --json-schema 1",{timeout:1e4,maxBuffer:10485760}),o=e.match(/\{[\s\S]*\}/),t=o?o[0]:e,n=JSON.parse(t),i=[];return Array.isArray(n)?i=n:n.modules&&Array.isArray(n.modules)?i=n.modules:n.data&&Array.isArray(n.data)&&(i=n.data),i.map(Ao).filter(r=>r.id&&r.name)}catch(e){return e.code==="ENOENT"?console.warn("\u26A0\uFE0F RapidKit Python Core not found in PATH"):e.killed?console.warn("\u26A0\uFE0F Python Core command timed out"):console.warn("\u26A0\uFE0F Failed to fetch modules from Python Core:",e.message),console.warn(" Using fallback module catalog (11 modules)"),Et}}async function Re(){let e=Date.now();return ne&&e-_t<$o||(ne=await So(),_t=e,ne.length===0&&(console.warn("\u26A0\uFE0F No modules found, using fallback catalog"),ne=Et)),ne}var Do=fileURLToPath(import.meta.url),Mt=w.dirname(Do),de=null;function Ko(){if(de)return de;let e=[w.join(Mt,"../../data/modules-embeddings.json"),w.join(Mt,"../data/modules-embeddings.json"),w.join(process.cwd(),"data/modules-embeddings.json")],o=null;for(let i of e)if(S.existsSync(i)){o=i;break}if(!o)throw new Error("embeddings file not found");let t=S.readFileSync(o,"utf-8"),n=JSON.parse(t);return Array.isArray(n)?de={model:"mock-or-text-embedding-3-small",dimension:n[0]?.embedding?.length||1536,generated_at:new Date().toISOString(),modules:n}:de=n,de}function Fo(e,o){if(e.length!==o.length)throw new Error("Vectors must have the same length");let t=0,n=0,i=0;for(let s=0;s<e.length;s++)t+=e[s]*o[s],n+=e[s]*e[s],i+=o[s]*o[s];let r=Math.sqrt(n)*Math.sqrt(i);return r===0?0:t/r}function Oo(e,o){let t=o.toLowerCase(),n=e.keywords.filter(i=>t.includes(i)||i.includes(t));return n.length>0?`Matches: ${n.slice(0,3).join(", ")}`:`Relevant for: ${e.useCases[0]}`}async function Dt(e,o=5){let t=Ko(),n=await Re(),i=await Ct(e),r=t.modules.map(s=>{let c=n.find(l=>l.id===s.id);if(!c)return null;let a=Fo(i,s.embedding);return {module:c,score:a,reason:Oo(c,e)}}).filter(s=>s!==null);return r.sort((s,c)=>c.score-s.score),r.slice(0,o)}var Wo=fileURLToPath(import.meta.url),Kt=w.dirname(Wo);async function Ft(){return (await import('inquirer')).default}function Lo(){return [w.join(Kt,"../../data/modules-embeddings.json"),w.join(Kt,"../data/modules-embeddings.json"),w.join(process.cwd(),"data/modules-embeddings.json")]}function Ot(){let e=Lo();for(let o of e)if(S.existsSync(o))try{let t=JSON.parse(S.readFileSync(o,"utf-8")),n=Array.isArray(t)?t:t.modules||[];return {exists:true,path:o,moduleCount:n.length,generatedAt:t.generated_at||null}}catch{continue}return {exists:false,path:null,moduleCount:0,generatedAt:null}}async function Ae(e=true,o){try{if(!$t()&&!At())return console.log(u.red(`
904
904
  \u274C OpenAI not initialized`)),console.log(u.yellow("Please set your API key:")),console.log(u.white(" rapidkit config set-api-key")),console.log(u.gray(` OR set: export OPENAI_API_KEY="sk-..."
905
905
  `)),false;console.log(u.blue(`
906
906
  \u{1F916} Generating AI embeddings for RapidKit modules...
907
907
  `)),console.log(u.gray("\u{1F4E1} Fetching modules from RapidKit..."));let t=await Re();console.log(u.green(`\u2713 Found ${t.length} modules
908
908
  `));let n=t.length*50/1e6*.02;if(console.log(u.cyan(`\u{1F4B0} Estimated cost: ~$${n.toFixed(3)}`)),console.log(u.gray(` (Based on ${t.length} modules at $0.02/1M tokens)
909
- `)),e){let s=await Kt(),{confirm:c}=await s.prompt([{type:"confirm",name:"confirm",message:"Generate embeddings now?",default:true}]);if(!c)return console.log(u.yellow(`
909
+ `)),e){let s=await Ft(),{confirm:c}=await s.prompt([{type:"confirm",name:"confirm",message:"Generate embeddings now?",default:true}]);if(!c)return console.log(u.yellow(`
910
910
  \u26A0\uFE0F Embeddings generation cancelled
911
- `)),false}let i=t.map(s=>`${s.name}. ${s.description}. ${s.longDescription}. Keywords: ${s.keywords.join(", ")}. Use cases: ${s.useCases.join(", ")}.`),r=Fe(`Generating embeddings for ${t.length} modules...`).start();try{let s=await Ct(i);r.succeed(`Generated embeddings for ${t.length} modules`);let c={model:"text-embedding-3-small",dimension:s[0].length,generated_at:new Date().toISOString(),modules:t.map((d,m)=>({id:d.id,name:d.name,embedding:s[m]}))},a=o||w.join(process.cwd(),"data","modules-embeddings.json"),l=w.dirname(a);return S.existsSync(l)||S.mkdirSync(l,{recursive:true}),S.writeFileSync(a,JSON.stringify(c,null,2)),console.log(u.green(`
911
+ `)),false}let i=t.map(s=>`${s.name}. ${s.description}. ${s.longDescription}. Keywords: ${s.keywords.join(", ")}. Use cases: ${s.useCases.join(", ")}.`),r=Fe(`Generating embeddings for ${t.length} modules...`).start();try{let s=await Rt(i);r.succeed(`Generated embeddings for ${t.length} modules`);let c={model:"text-embedding-3-small",dimension:s[0].length,generated_at:new Date().toISOString(),modules:t.map((d,m)=>({id:d.id,name:d.name,embedding:s[m]}))},a=o||w.join(process.cwd(),"data","modules-embeddings.json"),l=w.dirname(a);return S.existsSync(l)||S.mkdirSync(l,{recursive:true}),S.writeFileSync(a,JSON.stringify(c,null,2)),console.log(u.green(`
912
912
  \u2705 Embeddings generated successfully!`)),console.log(u.gray(`\u{1F4C1} Saved to: ${a}`)),console.log(u.gray(`\u{1F4CA} Size: ${t.length} modules, ${s[0].length} dimensions
913
913
  `)),true}catch(s){return r.fail("Failed to generate embeddings"),s.message?.includes("429")?(console.log(u.red(`
914
914
  \u274C OpenAI API quota exceeded`)),console.log(u.yellow(`Please check your billing: https://platform.openai.com/account/billing
@@ -918,29 +918,29 @@ Cancelled
918
918
  \u274C Error: ${s.message}
919
919
  `)),false}}catch(t){return console.log(u.red(`
920
920
  \u274C Failed to generate embeddings: ${t.message}
921
- `)),false}}async function Ot(e=true){if(Ft().exists)return true;if(console.log(u.yellow(`
921
+ `)),false}}async function Tt(e=true){if(Ot().exists)return true;if(console.log(u.yellow(`
922
922
  \u26A0\uFE0F Module embeddings not found`)),console.log(u.gray(`AI recommendations require embeddings to be generated.
923
923
  `)),!e)return console.log(u.red("\u274C Cannot generate embeddings in non-interactive mode")),console.log(u.white(`Run: rapidkit ai generate-embeddings
924
- `)),false;let t=await Kt(),{action:n}=await t.prompt([{type:"list",name:"action",message:"What would you like to do?",choices:[{name:"\u{1F680} Generate embeddings now (requires OpenAI API key)",value:"generate"},{name:"\u{1F4DD} Show me how to generate them manually",value:"manual"},{name:"\u274C Cancel",value:"cancel"}]}]);return n==="generate"?await Ae(true):(n==="manual"&&(console.log(u.cyan(`
924
+ `)),false;let t=await Ft(),{action:n}=await t.prompt([{type:"list",name:"action",message:"What would you like to do?",choices:[{name:"\u{1F680} Generate embeddings now (requires OpenAI API key)",value:"generate"},{name:"\u{1F4DD} Show me how to generate them manually",value:"manual"},{name:"\u274C Cancel",value:"cancel"}]}]);return n==="generate"?await Ae(true):(n==="manual"&&(console.log(u.cyan(`
925
925
  \u{1F4DD} To generate embeddings manually:
926
926
  `)),console.log(u.white("1. Get OpenAI API key from: https://platform.openai.com/api-keys")),console.log(u.white("2. Set the API key:")),console.log(u.gray(" rapidkit config set-api-key")),console.log(u.gray(` OR: export OPENAI_API_KEY="sk-..."
927
927
  `)),console.log(u.white("3. Generate embeddings:")),console.log(u.gray(` rapidkit ai generate-embeddings
928
928
  `)),console.log(u.cyan(`\u{1F4B0} Cost: ~$0.50 one-time
929
- `))),false)}async function Tt(){let e=Ft();return e.exists?(console.log(u.blue(`
929
+ `))),false)}async function Nt(){let e=Ot();return e.exists?(console.log(u.blue(`
930
930
  \u{1F504} Updating embeddings...`)),console.log(u.gray(`Current: ${e.moduleCount} modules`)),console.log(u.gray(`Generated: ${e.generatedAt||"unknown"}
931
931
  `)),await Ae(true,e.path)):(console.log(u.yellow(`
932
932
  \u26A0\uFE0F No existing embeddings found`)),console.log(u.gray(`Use: rapidkit ai generate-embeddings
933
- `)),false)}async function Nt(){return (await import('inquirer')).default}function Wt(e){let o=e.command("ai").description("AI-powered features");o.command("recommend").description("Get AI-powered module recommendations").argument("[query]",'What do you want to build? (e.g., "user authentication with email")').option("-n, --number <count>","Number of recommendations","5").option("--json","Output as JSON").action(async(t,n)=>{try{Le()||(console.log(u.yellow(`
933
+ `)),false)}async function Wt(){return (await import('inquirer')).default}function Lt(e){let o=e.command("ai").description("AI-powered features");o.command("recommend").description("Get AI-powered module recommendations").argument("[query]",'What do you want to build? (e.g., "user authentication with email")').option("-n, --number <count>","Number of recommendations","5").option("--json","Output as JSON").action(async(t,n)=>{try{Le()||(console.log(u.yellow(`
934
934
  \u26A0\uFE0F AI features are disabled`)),console.log(u.gray(`Enable with: rapidkit config ai enable
935
935
  `)),process.exit(1));let i=le();i?await Ce(i):(console.log(u.yellow(`
936
936
  \u26A0\uFE0F OpenAI API key not configured - using MOCK MODE for testing
937
937
  `)),console.log(u.gray("\u{1F4DD} Note: Mock embeddings provide approximate results for testing.")),console.log(u.gray(` For production, configure your OpenAI API key:
938
938
  `)),console.log(u.white(" 1. Get your key from: https://platform.openai.com/api-keys")),console.log(u.white(" 2. Configure it: rapidkit config set-api-key")),console.log(u.gray(` OR set: export OPENAI_API_KEY="sk-proj-..."
939
- `)),xt());let r=t;r||(r=(await(await Nt()).prompt([{type:"input",name:"query",message:"\u{1F916} What do you want to build?",validate:P=>P.length===0?"Please enter a description":P.length<3?"Please be more specific (at least 3 characters)":true}])).query),n.json||console.log(u.blue(`
939
+ `)),Pt());let r=t;r||(r=(await(await Wt()).prompt([{type:"input",name:"query",message:"\u{1F916} What do you want to build?",validate:P=>P.length===0?"Please enter a description":P.length<3?"Please be more specific (at least 3 characters)":true}])).query),n.json||console.log(u.blue(`
940
940
  \u{1F916} Analyzing your request...
941
- `)),await Ot(!n.json)||(console.log(u.yellow(`
941
+ `)),await Tt(!n.json)||(console.log(u.yellow(`
942
942
  \u26A0\uFE0F Cannot proceed without embeddings
943
- `)),process.exit(1));let c=parseInt(n.number,10),a=await Mt(r,c);if(a.length===0||a[0].score<.3)if(console.log(u.yellow(`
943
+ `)),process.exit(1));let c=parseInt(n.number,10),a=await Dt(r,c);if(a.length===0||a[0].score<.3)if(console.log(u.yellow(`
944
944
  \u26A0\uFE0F No matching modules found in RapidKit registry.
945
945
  `)),console.log(u.cyan(`\u{1F4A1} Options:
946
946
  `)),console.log(u.white("1. Create custom module:")),console.log(u.gray(" rapidkit modules scaffold <name> --category <category>")),console.log(u.gray(` Example: rapidkit modules scaffold blockchain-integration --category integrations
@@ -949,7 +949,7 @@ Cancelled
949
949
  `)),a.length>0)console.log(u.yellow(`\u26A0\uFE0F Low confidence matches found:
950
950
  `));else return;if(n.json){console.log(JSON.stringify({query:r,recommendations:a},null,2));return}console.log(u.green.bold(`\u{1F4E6} Recommended Modules:
951
951
  `)),a.forEach((p,y)=>{let P=(p.score*100).toFixed(1),v=p.score>.8?" \u2B50":"";console.log(u.bold(`${y+1}. ${p.module.name}${v}`)),console.log(u.gray(` ${p.module.description}`)),console.log(u.cyan(` Match: ${P}%`)+u.gray(` - ${p.reason}`)),console.log(u.yellow(` Category: ${p.module.category}`)),p.module.dependencies.length>0&&console.log(u.magenta(` Requires: ${p.module.dependencies.join(", ")}`)),console.log();});let l=a.slice(0,3).map(p=>p.module.id);console.log(u.cyan("\u{1F4A1} Quick install (top 3):")),console.log(u.white(` rapidkit add module ${l.join(" ")}
952
- `));let d=await Nt(),{shouldInstall:m}=await d.prompt([{type:"confirm",name:"shouldInstall",message:"Would you like to install these modules now?",default:false}]);if(m){let{selectedModules:p}=await d.prompt([{type:"checkbox",name:"selectedModules",message:"Select modules to install:",choices:a.map(y=>({name:`${y.module.name} - ${y.module.description}`,value:y.module.id,checked:y.score>.7}))}]);p.length>0?(console.log(u.blue(`
952
+ `));let d=await Wt(),{shouldInstall:m}=await d.prompt([{type:"confirm",name:"shouldInstall",message:"Would you like to install these modules now?",default:false}]);if(m){let{selectedModules:p}=await d.prompt([{type:"checkbox",name:"selectedModules",message:"Select modules to install:",choices:a.map(y=>({name:`${y.module.name} - ${y.module.description}`,value:y.module.id,checked:y.score>.7}))}]);p.length>0?(console.log(u.blue(`
953
953
  \u{1F4E6} Installing ${p.length} modules...
954
954
  `)),console.log(u.gray(`Command: rapidkit add module ${p.join(" ")}`)),console.log(u.yellow(`
955
955
  \u26A0\uFE0F Note: Module installation not yet implemented`)),console.log(u.gray(`Coming soon in next version!
@@ -977,28 +977,28 @@ No modules selected
977
977
  `))),process.exit(n?0:1);}catch(t){a.error("Failed to generate embeddings:",t.message),process.exit(1);}}),o.command("update-embeddings").description("Update existing embeddings with latest modules").action(async()=>{try{let t=le();t||(console.log(u.red(`
978
978
  \u274C OpenAI API key not configured
979
979
  `)),console.log(u.white(`Set your API key: rapidkit config set-api-key
980
- `)),process.exit(1)),Ce(t);let n=await Tt();process.exit(n?0:1);}catch(t){a.error("Failed to update embeddings:",t.message),process.exit(1);}});}function Ue(e){if(!e||typeof e!="object")return null;let o=e.code;return o==="PYTHON_NOT_FOUND"||o==="BRIDGE_VENV_BOOTSTRAP_FAILED"?o:null}function Go(e){let o=e.trim().toLowerCase();return o?o.startsWith("fastapi")?"fastapi":o.startsWith("nestjs")?"nestjs":null:null}function Ut(e,o){let t=e.indexOf(o);if(t>=0&&t+1<e.length)return e[t+1];let n=e.find(i=>i.startsWith(`${o}=`));if(n)return n.slice(o.length+1)}async function He(e,o){if(e.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(e[0]!=="create")return 1;if(e[1]!=="project")return process.stderr.write(`RapidKit (npm) could not run the Python core engine for \`create\`.
980
+ `)),process.exit(1)),Ce(t);let n=await Nt();process.exit(n?0:1);}catch(t){a.error("Failed to update embeddings:",t.message),process.exit(1);}});}function Ue(e){if(!e||typeof e!="object")return null;let o=e.code;return o==="PYTHON_NOT_FOUND"||o==="BRIDGE_VENV_BOOTSTRAP_FAILED"?o:null}function Vo(e){let o=e.trim().toLowerCase();return o?o.startsWith("fastapi")?"fastapi":o.startsWith("nestjs")?"nestjs":null:null}function Ht(e,o){let t=e.indexOf(o);if(t>=0&&t+1<e.length)return e[t+1];let n=e.find(i=>i.startsWith(`${o}=`));if(n)return n.slice(o.length+1)}async function He(e,o){if(e.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(e[0]!=="create")return 1;if(e[1]!=="project")return process.stderr.write(`RapidKit (npm) could not run the Python core engine for \`create\`.
981
981
  Reason: ${o}.
982
982
  Install Python 3.10+ to use the interactive wizard and full kit catalog.
983
983
  `),1;let i=e[2],r=e[3];if(!i||!r)return process.stderr.write(`Usage: rapidkit create project <kit> <name> [--output <dir>]
984
984
  Tip: offline fallback supports only fastapi* and nestjs* kits.
985
- `),1;let s=Go(i);if(!s)return process.stderr.write(`RapidKit (npm) could not run the Python core engine to create this kit.
985
+ `),1;let s=Vo(i);if(!s)return process.stderr.write(`RapidKit (npm) could not run the Python core engine to create this kit.
986
986
  Reason: ${o}.
987
987
  Requested kit: ${i}
988
988
  Offline fallback only supports: fastapi.standard, nestjs.standard (and their shorthands).
989
989
  Install Python 3.10+ to access all kits.
990
- `),1;let c=Ut(e,"--output")||process.cwd(),a=w.resolve(c,r),l=e.includes("--skip-git")||e.includes("--no-git"),d=e.includes("--skip-install");try{if(await k.ensureDir(w.dirname(a)),await k.pathExists(a))return process.stderr.write(`\u274C Directory "${a}" already exists
990
+ `),1;let c=Ht(e,"--output")||process.cwd(),a=w.resolve(c,r),l=e.includes("--skip-git")||e.includes("--no-git"),d=e.includes("--skip-install");try{if(await k.ensureDir(w.dirname(a)),await k.pathExists(a))return process.stderr.write(`\u274C Directory "${a}" already exists
991
991
  `),1;let m="pip",p=me(process.cwd());if(p)try{let{readWorkspaceMarker:y}=await import('./workspace-marker-IOPQ42A7.js'),P=await y(p);P?.metadata?.npm?.installMethod&&(m=P.metadata.npm.installMethod,console.log(`[DEBUG] Detected workspace engine: ${m}`));}catch(y){console.log("[DEBUG] Failed to read workspace marker:",y);}else console.log("[DEBUG] No workspace found, using default engine: pip");if(await k.ensureDir(a),await pt(a,{project_name:r,template:s,kit_name:i,skipGit:l,skipInstall:d,engine:m}),p){let{syncWorkspaceProjects:y}=await import('./workspace-LZZGJRGV.js');await y(p,true);}return 0}catch(m){return process.stderr.write(`RapidKit (npm) offline fallback failed: ${m?.message??m}
992
- `),1}}async function Vo(e){let o=new Set(["--yes","-y","--skip-git","--skip-install","--debug","--dry-run","--no-update-check","--create-workspace","--no-workspace"]);if(e[0]==="create"&&e[1]==="workspace")try{let t=e.includes("--yes")||e.includes("-y"),n=e.includes("--skip-git")||e.includes("--no-git"),i=e[2]&&!e[2].startsWith("-")?e[2]:void 0,r=Ut(e,"--install-method"),s=r==="poetry"||r==="venv"||r==="pipx"?r:void 0,c=i||(t?"my-workspace":(await ue.prompt([{type:"input",name:"workspaceName",message:"Workspace name:",default:"my-workspace"}])).workspaceName);if(!c||!c.trim())return process.stderr.write(`Workspace name is required.
992
+ `),1}}async function Uo(e){let o=new Set(["--yes","-y","--skip-git","--skip-install","--debug","--dry-run","--no-update-check","--create-workspace","--no-workspace"]);if(e[0]==="create"&&e[1]==="workspace")try{let t=e.includes("--yes")||e.includes("-y"),n=e.includes("--skip-git")||e.includes("--no-git"),i=e[2]&&!e[2].startsWith("-")?e[2]:void 0,r=Ht(e,"--install-method"),s=r==="poetry"||r==="venv"||r==="pipx"?r:void 0,c=i||(t?"my-workspace":(await ue.prompt([{type:"input",name:"workspaceName",message:"Workspace name:",default:"my-workspace"}])).workspaceName);if(!c||!c.trim())return process.stderr.write(`Workspace name is required.
993
993
  `),1;try{Me(c);}catch(m){if(m instanceof F)return process.stderr.write(`${m.message}
994
994
  `),1;throw m}let a=w.resolve(process.cwd(),c);if(await k.pathExists(a))return process.stderr.write(`\u274C Directory "${c}" already exists
995
995
  `),1;let l=await z(),d=l.author||process.env.USER||"RapidKit User";if(!t){let m=await ue.prompt([{type:"input",name:"author",message:"Author name:",default:d}]);m.author?.trim()&&(d=m.author.trim());}return await ve(c,{skipGit:n,yes:t,userConfig:{...l,author:d},installMethod:s}),0}catch(t){return process.stderr.write(`RapidKit (npm) failed to create workspace: ${t?.message??t}
996
- `),1}try{if(e[0]==="create"&&e[1]==="project"){let t=e.includes("--create-workspace"),n=e.includes("--no-workspace"),i=e.includes("--yes")||e.includes("-y"),r=e.includes("--skip-git")||e.includes("--no-git");if(!!!Ee(process.cwd())){if(t)await Y(process.cwd(),{skipGit:r,yes:i,userConfig:await z()});else if(!n)if(i)await Y(process.cwd(),{skipGit:r,yes:true,userConfig:await z()});else {let{createWs:a}=await ue.prompt([{type:"confirm",name:"createWs",message:"This project will be created outside a RapidKit workspace. Create and register a workspace here?",default:true}]);a&&await Y(process.cwd(),{skipGit:r,yes:false,userConfig:await z()});}}let c=e.filter(a=>{let l=a.split("=")[0];return !o.has(a)&&!o.has(l)});try{await c$1();let a$1=await d(c,{cwd:process.cwd()});if(a$1===0){let l=me(process.cwd());if(l){try{let m=e[3];if(m){let p=e.indexOf("--output"),y=p>=0?e[p+1]:".",P=w.resolve(process.cwd(),y,m),v=w.join(l,".python-version"),C=w.join(P,".python-version");if(S.existsSync(v)&&S.existsSync(P)){let _=S.readFileSync(v,"utf-8");S.writeFileSync(C,_.trim()+`
997
- `),a.debug(`Synced Python version ${_.trim()} from workspace to ${m}`);}}}catch(m){a.debug("Could not sync Python version from workspace:",m);}let{syncWorkspaceProjects:d}=await import('./workspace-LZZGJRGV.js');await d(l,true);}}return a$1}catch(a){let l=Ue(a);return l?await He(c,l):(process.stderr.write(`RapidKit (npm) failed to run the Python core engine: ${a?.message??a}
996
+ `),1}try{if(e[0]==="create"&&e[1]==="project"){let t=e.includes("--create-workspace"),n=e.includes("--no-workspace"),i=e.includes("--yes")||e.includes("-y"),r=e.includes("--skip-git")||e.includes("--no-git");if(!!!_e(process.cwd())){if(t)await Y(process.cwd(),{skipGit:r,yes:i,userConfig:await z()});else if(!n)if(i)await Y(process.cwd(),{skipGit:r,yes:true,userConfig:await z()});else {let{createWs:a}=await ue.prompt([{type:"confirm",name:"createWs",message:"This project will be created outside a RapidKit workspace. Create and register a workspace here?",default:true}]);a&&await Y(process.cwd(),{skipGit:r,yes:false,userConfig:await z()});}}let c=e.filter(a=>{let l=a.split("=")[0];return !o.has(a)&&!o.has(l)});try{await c$1();let a$1=await d(c,{cwd:process.cwd()});if(a$1===0){let l=me(process.cwd());if(l){try{let m=e[3];if(m){let p=e.indexOf("--output"),y=p>=0?e[p+1]:".",P=w.resolve(process.cwd(),y,m),v=w.join(l,".python-version"),C=w.join(P,".python-version");if(S.existsSync(v)&&S.existsSync(P)){let E=S.readFileSync(v,"utf-8");S.writeFileSync(C,E.trim()+`
997
+ `),a.debug(`Synced Python version ${E.trim()} from workspace to ${m}`);}}}catch(m){a.debug("Could not sync Python version from workspace:",m);}let{syncWorkspaceProjects:d}=await import('./workspace-LZZGJRGV.js');await d(l,true);}}return a$1}catch(a){let l=Ue(a);return l?await He(c,l):(process.stderr.write(`RapidKit (npm) failed to run the Python core engine: ${a?.message??a}
998
998
  `),1)}}if(e[0]==="create"&&e[1]!=="project")try{await c$1();let t=await d(e,{cwd:process.cwd()});if(t===0){let n=me(process.cwd());if(n){let{syncWorkspaceProjects:i}=await import('./workspace-LZZGJRGV.js');await i(n,true);}}return t}catch(t){let n=Ue(t);return n?await He(e,n):(process.stderr.write(`RapidKit (npm) failed to run the Python core engine: ${t?.message??t}
999
999
  `),1)}return await c$1(),await d(e,{cwd:process.cwd()})}catch(t){let n=Ue(t);return n?await He(e,n):(process.stderr.write(`RapidKit (npm) failed to run the Python core engine: ${t?.message??t}
1000
- `),1)}}var Lt=["dev","start","build","test","lint","format","create","help","--help","-h"];function Ht(e){let o=e;for(;;){let t=w.join(o,".rapidkit","context.json");if(S.existsSync(t))return t;let n=w.dirname(o);if(n===o)break;o=n;}return null}function Ee(e){let o=e;for(;;){let t=w.join(o,".rapidkit-workspace");if(S.existsSync(t))return t;let n=w.dirname(o);if(n===o)break;o=n;}return null}function me(e){let o=e;for(;;){let t=w.join(o,".rapidkit-workspace");if(S.existsSync(t))return o;let n=w.dirname(o);if(n===o)break;o=n;}return null}async function Gt(e,o,t){return await new Promise(n=>{let i=spawn(e,o,{stdio:"inherit",cwd:t,shell:process.platform==="win32"});i.on("close",r=>n(r??1)),i.on("error",()=>n(1));})}async function Vt(e){let o="poetry";try{let{readWorkspaceMarker:t}=await import('./workspace-marker-IOPQ42A7.js'),i=(await t(e))?.metadata?.npm?.installMethod;(i==="poetry"||i==="venv"||i==="pipx"||i==="pip")&&(o=i);}catch{}if(o==="poetry")return await Gt("poetry",["install","--no-root"],e);if(o==="venv"){let t=w.join(e,".venv",process.platform==="win32"?"Scripts":"bin",process.platform==="win32"?"python.exe":"python");return await k.pathExists(t)?await Gt(t,["-m","pip","install","--upgrade","rapidkit-core"],e):(process.stderr.write(`Workspace virtualenv not found (.venv).
1001
- `),1)}return 0}async function Uo(e){let o=await S.promises.readdir(e,{withFileTypes:true}),t=[];for(let n of o){if(!n.isDirectory()||n.name.startsWith("."))continue;let i=w.join(e,n.name),r=w.join(i,".rapidkit","context.json"),s=w.join(i,".rapidkit","project.json");(await k.pathExists(r)||await k.pathExists(s))&&t.push(i);}return t}function Ho(e){let o="my-workspace",t=1;for(;;){let n=t===1?o:`${o}-${t}`,i=w.join(e,n);if(!S.existsSync(i))return {name:n,targetPath:i};t+=1;}}async function qo(e){let o=process.cwd();if(e.length>1)return await d(e,{cwd:o});let t=me(o),n=Ht(o),i=n?w.dirname(w.dirname(n)):null;if(i&&i!==t)return await d(["init"],{cwd:i});if(t&&o===t){let r=await Vt(t);if(r!==0)return r;let s=await Uo(t);for(let c of s){let a=await d(["init"],{cwd:c});if(a!==0)return a}return 0}if(!t){let r=await z(),{name:s}=Ho(o);await ve(s,{yes:true,userConfig:r});let c=w.join(o,s);return await Vt(c)}return await d(e,{cwd:o})}async function Jo(){let e=process.cwd(),o=process.argv.slice(2);if(o[0]==="create")return false;try{let a=o[0],l=!a||a==="--help"||a==="-h"||a==="help";if(Ee(e)&&l){let m=await d(a?["--help"]:[],{cwd:e});process.exit(m);}}catch{}try{let a=o[0],l=a==="shell"&&o[1]==="activate",d$1=a==="create",m=await tt(e,{cwd:e,timeoutMs:1200});if(m.ok&&m.data?.isRapidkitProject&&m.data.engine==="python"&&!l&&!d$1){let p=await d(process.argv.slice(2),{cwd:e});process.exit(p);}}catch{}let t=Ht(e),n=process.platform==="win32",i=n?[w.join(e,"rapidkit.cmd"),w.join(e,"rapidkit"),w.join(e,".rapidkit","rapidkit.cmd"),w.join(e,".rapidkit","rapidkit")]:[w.join(e,"rapidkit"),w.join(e,".rapidkit","rapidkit")],r=null;for(let a of i)if(await k.pathExists(a)){r=a;break}let s=o[0],c=s==="create";if(r&&s&&Lt.includes(s)&&!c){a.debug(`Delegating to local CLI: ${r} ${o.join(" ")}`);let a$1=spawn(r,o,{stdio:"inherit",cwd:e,shell:n});return a$1.on("close",l=>{process.exit(l??0);}),a$1.on("error",l=>{a.error(`Failed to run local rapidkit: ${l.message}`),process.exit(1);}),true}if(t&&await k.pathExists(t))try{if((await k.readJson(t)).engine==="pip"){let l=o[0],m=process.platform==="win32"?[w.join(e,"rapidkit.cmd"),w.join(e,"rapidkit"),w.join(e,".rapidkit","rapidkit.cmd"),w.join(e,".rapidkit","rapidkit")]:[w.join(e,"rapidkit"),w.join(e,".rapidkit","rapidkit")],p=null;for(let P of m)if(await k.pathExists(P)){p=P;break}if(p&&l&&Lt.includes(l)){a.debug(`Delegating to local CLI (early detection): ${p} ${o.join(" ")}`);let P=spawn(p,o,{stdio:"inherit",cwd:e});return P.on("close",v=>process.exit(v??0)),P.on("error",v=>{a.error(`Failed to run local rapidkit: ${v.message}`),process.exit(1);}),true}if(l==="shell"&&o[1]==="activate"){let P=`# RapidKit: activation snippet - eval "$(rapidkit shell activate)"
1000
+ `),1)}}var Gt=["dev","start","build","test","lint","format","create","help","--help","-h"];function qt(e){let o=e;for(;;){let t=w.join(o,".rapidkit","context.json");if(S.existsSync(t))return t;let n=w.dirname(o);if(n===o)break;o=n;}return null}function _e(e){let o=e;for(;;){let t=w.join(o,".rapidkit-workspace");if(S.existsSync(t))return t;let n=w.dirname(o);if(n===o)break;o=n;}return null}function me(e){let o=e;for(;;){let t=w.join(o,".rapidkit-workspace");if(S.existsSync(t))return o;let n=w.dirname(o);if(n===o)break;o=n;}return null}async function Vt(e,o,t){return await new Promise(n=>{let i=spawn(e,o,{stdio:"inherit",cwd:t,shell:process.platform==="win32"});i.on("close",r=>n(r??1)),i.on("error",()=>n(1));})}async function Ut(e){let o="poetry";try{let{readWorkspaceMarker:t}=await import('./workspace-marker-IOPQ42A7.js'),i=(await t(e))?.metadata?.npm?.installMethod;(i==="poetry"||i==="venv"||i==="pipx"||i==="pip")&&(o=i);}catch{}if(o==="poetry")return await Vt("poetry",["install","--no-root"],e);if(o==="venv"){let t=w.join(e,".venv",process.platform==="win32"?"Scripts":"bin",process.platform==="win32"?"python.exe":"python");return await k.pathExists(t)?await Vt(t,["-m","pip","install","--upgrade","rapidkit-core"],e):(process.stderr.write(`Workspace virtualenv not found (.venv).
1001
+ `),1)}return 0}async function Ho(e){let o=await S.promises.readdir(e,{withFileTypes:true}),t=[];for(let n of o){if(!n.isDirectory()||n.name.startsWith("."))continue;let i=w.join(e,n.name),r=w.join(i,".rapidkit","context.json"),s=w.join(i,".rapidkit","project.json");(await k.pathExists(r)||await k.pathExists(s))&&t.push(i);}return t}function qo(e){let o="my-workspace",t=1;for(;;){let n=t===1?o:`${o}-${t}`,i=w.join(e,n);if(!S.existsSync(i))return {name:n,targetPath:i};t+=1;}}async function Jo(e){let o=process.cwd();if(e.length>1)return await d(e,{cwd:o});let t=me(o),n=qt(o),i=n?w.dirname(w.dirname(n)):null;if(i&&i!==t)return await d(["init"],{cwd:i});if(t&&o===t){let r=await Ut(t);if(r!==0)return r;let s=await Ho(t);for(let c of s){let a=await d(["init"],{cwd:c});if(a!==0)return a}return 0}if(!t){let r=await z(),{name:s}=qo(o);await ve(s,{yes:true,userConfig:r});let c=w.join(o,s);return await Ut(c)}return await d(e,{cwd:o})}async function zo(){let e=process.cwd(),o=process.argv.slice(2);if(o[0]==="create")return false;try{let a=o[0],l=!a||a==="--help"||a==="-h"||a==="help";if(_e(e)&&l){let m=await d(a?["--help"]:[],{cwd:e});process.exit(m);}}catch{}try{let a=o[0],l=a==="shell"&&o[1]==="activate",d$1=a==="create",m=await tt(e,{cwd:e,timeoutMs:1200});if(m.ok&&m.data?.isRapidkitProject&&m.data.engine==="python"&&!l&&!d$1){let p=await d(process.argv.slice(2),{cwd:e});process.exit(p);}}catch{}let t=qt(e),n=process.platform==="win32",i=n?[w.join(e,"rapidkit.cmd"),w.join(e,"rapidkit"),w.join(e,".rapidkit","rapidkit.cmd"),w.join(e,".rapidkit","rapidkit")]:[w.join(e,"rapidkit"),w.join(e,".rapidkit","rapidkit")],r=null;for(let a of i)if(await k.pathExists(a)){r=a;break}let s=o[0],c=s==="create";if(r&&s&&Gt.includes(s)&&!c){a.debug(`Delegating to local CLI: ${r} ${o.join(" ")}`);let a$1=spawn(r,o,{stdio:"inherit",cwd:e,shell:n});return a$1.on("close",l=>{process.exit(l??0);}),a$1.on("error",l=>{a.error(`Failed to run local rapidkit: ${l.message}`),process.exit(1);}),true}if(t&&await k.pathExists(t))try{if((await k.readJson(t)).engine==="pip"){let l=o[0],m=process.platform==="win32"?[w.join(e,"rapidkit.cmd"),w.join(e,"rapidkit"),w.join(e,".rapidkit","rapidkit.cmd"),w.join(e,".rapidkit","rapidkit")]:[w.join(e,"rapidkit"),w.join(e,".rapidkit","rapidkit")],p=null;for(let P of m)if(await k.pathExists(P)){p=P;break}if(p&&l&&Gt.includes(l)){a.debug(`Delegating to local CLI (early detection): ${p} ${o.join(" ")}`);let P=spawn(p,o,{stdio:"inherit",cwd:e});return P.on("close",v=>process.exit(v??0)),P.on("error",v=>{a.error(`Failed to run local rapidkit: ${v.message}`),process.exit(1);}),true}if(l==="shell"&&o[1]==="activate"){let P=`# RapidKit: activation snippet - eval "$(rapidkit shell activate)"
1002
1002
  VENV='.venv'
1003
1003
  if [ -f "$VENV/bin/activate" ]; then
1004
1004
  . "$VENV/bin/activate"
@@ -1011,7 +1011,7 @@ export PATH="$(pwd)/.rapidkit:$(pwd):$PATH"
1011
1011
  \u2705 Activation snippet \u2014 run the following to activate this project in your current shell:
1012
1012
  `)),console.log(P),console.log(u.gray(`
1013
1013
  \u{1F4A1} After activation you can run: rapidkit dev
1014
- `)),process.exit(0);}let y=await d(o,{cwd:e});process.exit(y);}}catch{}return false}var J=null,_e=false,V=new Command;async function Bo(e){if(e.length===0)return false;let o=e[0],t=e[1];if(o==="shell"&&t==="activate"||o==="workspace"||o==="doctor"||o==="ai"||o==="config")return false;if(e.includes("--tui"))return true;if(o==="--help"||o==="-h"||o==="help"||o==="--version"||o==="-V"||e.includes("--template")||e.includes("-t"))return false;let n=new Set(["--yes","-y","--skip-git","--skip-install","--debug","--dry-run","--no-update-check","--create-workspace","--no-workspace"]);if(e.some(r=>n.has(r)))return false;let i=await g();return i?i.has(o):!!(a$1.has(o)||e.length>1)}V.name("rapidkit").description("Create RapidKit workspaces and projects").version(c());V.addHelpText("beforeAll",`RapidKit
1014
+ `)),process.exit(0);}let y=await d(o,{cwd:e});process.exit(y);}}catch{}return false}var J=null,Ee=false,V=new Command;async function Yo(e){if(e.length===0)return false;let o=e[0],t=e[1];if(o==="shell"&&t==="activate"||o==="workspace"||o==="doctor"||o==="ai"||o==="config")return false;if(e.includes("--tui"))return true;if(o==="--help"||o==="-h"||o==="help"||o==="--version"||o==="-V"||e.includes("--template")||e.includes("-t"))return false;let n=new Set(["--yes","-y","--skip-git","--skip-install","--debug","--dry-run","--no-update-check","--create-workspace","--no-workspace"]);if(e.some(r=>n.has(r)))return false;let i=await g();return i?i.has(o):!!(a$1.has(o)||e.length>1)}V.name("rapidkit").description("Create RapidKit workspaces and projects").version(c());V.addHelpText("beforeAll",`RapidKit
1015
1015
 
1016
1016
  Global CLI
1017
1017
  Create RapidKit workspaces and projects
@@ -1027,7 +1027,7 @@ Project Commands
1027
1027
  Use "rapidkit help <command>" for more information.
1028
1028
  `);V.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(e,o)=>{try{o.debug&&(a.setDebug(true),a.debug("Debug mode enabled"));let t=await z();a.debug("User config loaded",t);let n=await Ze();a.debug("RapidKit config loaded",n);let i=et(t,n,{author:o.author,skipGit:o.skipGit});a.debug("Merged config",i),o.updateCheck!==false&&await b(),console.log(u.blue.bold(`
1029
1029
  \u{1F680} Welcome to RapidKit!
1030
- `)),e||(Yo(),process.exit(0));try{Me(e);}catch(c){throw c instanceof F&&(a.error(`
1030
+ `)),e||(Qo(),process.exit(0));try{Me(e);}catch(c){throw c instanceof F&&(a.error(`
1031
1031
  \u274C ${c.message}`),c.details&&a.warn(`\u{1F4A1} ${c.details}
1032
1032
  `),process.exit(1)),c}let r=w.resolve(process.cwd(),e);J=r,await k.pathExists(r)&&(a.error(`
1033
1033
  \u274C Directory "${e}" already exists`),console.log(u.cyan(`
@@ -1035,17 +1035,17 @@ Use "rapidkit help <command>" for more information.
1035
1035
  `)),process.exit(1));let s=!!o.template;if(o.dryRun){console.log(u.cyan(`
1036
1036
  \u{1F50D} Dry-run mode - showing what would be created:
1037
1037
  `)),console.log(u.white("\u{1F4C2} Path:"),r),console.log(u.white("\u{1F4E6} Type:"),s?`Project (${o.template})`:"Workspace"),console.log();return}if(!o.yes&&!s?await ue.prompt([{type:"input",name:"author",message:"Author name:",default:process.env.USER||"RapidKit User"}]):o.yes&&console.log(u.gray(`Using default values (--yes flag)
1038
- `)),s){let c=String(o.template||"").trim(),a$1=c.toLowerCase(),l=a$1==="fastapi"?"fastapi.standard":a$1==="nestjs"?"nestjs.standard":c;if(!!!Ee(process.cwd())){if(o.createWorkspace)await Y(process.cwd(),{skipGit:o.skipGit,yes:o.yes,userConfig:t});else if(!o.noWorkspace)if(o.yes)await Y(process.cwd(),{skipGit:o.skipGit,yes:true,userConfig:t});else {let{createWs:P}=await ue.prompt([{type:"confirm",name:"createWs",message:"This project will be created outside a RapidKit workspace. Create and register a workspace here?",default:true}]);P&&await Y(process.cwd(),{skipGit:o.skipGit,yes:false,userConfig:t});}}let m=["create","project",l,e,"--output",process.cwd(),"--install-essentials"],p=await d(m,{cwd:process.cwd()});p!==0&&process.exit(p);let y=Ee(process.cwd());if(y){let P=w.dirname(y),v=w.join(P,".python-version"),C=w.join(r,".python-version");try{if(await k.pathExists(v)){let _=S.readFileSync(v,"utf-8");S.writeFileSync(C,_.trim()+`
1039
- `),a.debug(`Synced Python version ${_.trim()} from workspace to project`);}}catch(_){a.debug("Could not sync Python version from workspace:",_);}}if(!o.skipInstall){let P=await d(["init",r],{cwd:process.cwd()});if(P!==0&&process.exit(P),y){let v=w.dirname(y),C=w.join(v,".python-version"),_=w.join(r,".python-version");try{if(await k.pathExists(C)){let M=S.readFileSync(C,"utf-8");S.writeFileSync(_,M.trim()+`
1038
+ `)),s){let c=String(o.template||"").trim(),a$1=c.toLowerCase(),l=a$1==="fastapi"?"fastapi.standard":a$1==="nestjs"?"nestjs.standard":c;if(!!!_e(process.cwd())){if(o.createWorkspace)await Y(process.cwd(),{skipGit:o.skipGit,yes:o.yes,userConfig:t});else if(!o.noWorkspace)if(o.yes)await Y(process.cwd(),{skipGit:o.skipGit,yes:true,userConfig:t});else {let{createWs:P}=await ue.prompt([{type:"confirm",name:"createWs",message:"This project will be created outside a RapidKit workspace. Create and register a workspace here?",default:true}]);P&&await Y(process.cwd(),{skipGit:o.skipGit,yes:false,userConfig:t});}}let m=["create","project",l,e,"--output",process.cwd(),"--install-essentials"],p=await d(m,{cwd:process.cwd()});p!==0&&process.exit(p);let y=_e(process.cwd());if(y){let P=w.dirname(y),v=w.join(P,".python-version"),C=w.join(r,".python-version");try{if(await k.pathExists(v)){let E=S.readFileSync(v,"utf-8");S.writeFileSync(C,E.trim()+`
1039
+ `),a.debug(`Synced Python version ${E.trim()} from workspace to project`);}}catch(E){a.debug("Could not sync Python version from workspace:",E);}}if(!o.skipInstall){let P=await d(["init",r],{cwd:process.cwd()});if(P!==0&&process.exit(P),y){let v=w.dirname(y),C=w.join(v,".python-version"),E=w.join(r,".python-version");try{if(await k.pathExists(C)){let M=S.readFileSync(C,"utf-8");S.writeFileSync(E,M.trim()+`
1040
1040
  `),a.debug(`Re-synced Python version ${M.trim()} after init`);}}catch(M){a.debug("Could not re-sync Python version after init:",M);}}}}else await ve(e,{skipGit:o.skipGit,dryRun:o.dryRun,yes:o.yes,userConfig:i,installMethod:o.installMethod});}catch(t){t instanceof F?(a.error(`
1041
1041
  \u274C ${t.message}`),t.details&&a.warn(`\u{1F4A1} ${t.details}`),a.debug("Error code:",t.code)):(a.error(`
1042
- \u274C An unexpected error occurred:`),console.error(t)),process.exit(1);}finally{J=null;}});Wt(V);bt(V);V.command("shell <action>").description("Shell helpers (activate virtualenv in current shell)").action(async e=>{e!=="activate"&&(console.log(u.red(`Unknown shell command: ${e}`)),process.exit(1));let o=process.cwd();function t(a){let l=a;for(;;){let d=w.join(l,".rapidkit","context.json");if(S.existsSync(d))return d;let m=w.dirname(l);if(m===l)break;l=m;}return null}let n=t(o);function i(a){let l=a;for(;;){let d=w.join(l,".venv"),m=w.join(l,".rapidkit","activate");if(S.existsSync(m)||S.existsSync(d))return {venv:d,activateFile:m};let p=w.dirname(l);if(p===l)break;l=p;}return null}let r=i(o);!n&&!r&&(console.log(u.yellow("No RapidKit project found in this directory")),process.exit(1));let s;r&&S.existsSync(r.activateFile)?s=r.activateFile:r&&S.existsSync(r.venv)?s=process.platform==="win32"?w.join(r.venv,"Scripts","activate"):w.join(r.venv,"bin","activate"):(console.log(u.yellow("No virtual environment found")),process.exit(1));let c=process.platform==="win32";console.log(c?`call "${s}"`:`. "${s}"`);});V.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 e=>{await wt(e);});V.command("workspace <action>").description("Manage RapidKit workspaces (list, sync)").action(async e=>{if(e==="list"){let{listWorkspaces:o}=await import('./workspace-LZZGJRGV.js');await o();}else if(e==="sync"){let o=me(process.cwd());o||(console.log(u.red("\u274C Not inside a RapidKit workspace")),console.log(u.gray("\u{1F4A1} Run this command from within a workspace directory")),process.exit(1));let{syncWorkspaceProjects:t}=await import('./workspace-LZZGJRGV.js');console.log(u.cyan(`\u{1F4C2} Scanning workspace: ${w.basename(o)}`)),await t(o);}else console.log(u.red(`Unknown workspace action: ${e}`)),console.log(u.gray("Available: list, sync")),process.exit(1);});function Yo(){console.log(u.white(`Usage:
1042
+ \u274C An unexpected error occurred:`),console.error(t)),process.exit(1);}finally{J=null;}});Lt(V);xt(V);V.command("shell <action>").description("Shell helpers (activate virtualenv in current shell)").action(async e=>{e!=="activate"&&(console.log(u.red(`Unknown shell command: ${e}`)),process.exit(1));let o=process.cwd();function t(a){let l=a;for(;;){let d=w.join(l,".rapidkit","context.json");if(S.existsSync(d))return d;let m=w.dirname(l);if(m===l)break;l=m;}return null}let n=t(o);function i(a){let l=a;for(;;){let d=w.join(l,".venv"),m=w.join(l,".rapidkit","activate");if(S.existsSync(m)||S.existsSync(d))return {venv:d,activateFile:m};let p=w.dirname(l);if(p===l)break;l=p;}return null}let r=i(o);!n&&!r&&(console.log(u.yellow("No RapidKit project found in this directory")),process.exit(1));let s;r&&S.existsSync(r.activateFile)?s=r.activateFile:r&&S.existsSync(r.venv)?s=process.platform==="win32"?w.join(r.venv,"Scripts","activate"):w.join(r.venv,"bin","activate"):(console.log(u.yellow("No virtual environment found")),process.exit(1));let c=process.platform==="win32";console.log(c?`call "${s}"`:`. "${s}"`);});V.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 e=>{await kt(e);});V.command("workspace <action>").description("Manage RapidKit workspaces (list, sync)").action(async e=>{if(e==="list"){let{listWorkspaces:o}=await import('./workspace-LZZGJRGV.js');await o();}else if(e==="sync"){let o=me(process.cwd());o||(console.log(u.red("\u274C Not inside a RapidKit workspace")),console.log(u.gray("\u{1F4A1} Run this command from within a workspace directory")),process.exit(1));let{syncWorkspaceProjects:t}=await import('./workspace-LZZGJRGV.js');console.log(u.cyan(`\u{1F4C2} Scanning workspace: ${w.basename(o)}`)),await t(o);}else console.log(u.red(`Unknown workspace action: ${e}`)),console.log(u.gray("Available: list, sync")),process.exit(1);});function Qo(){console.log(u.white(`Usage:
1043
1043
  `)),console.log(u.cyan(" npx rapidkit <workspace-name> [options]")),console.log(u.cyan(` npx rapidkit create <...>
1044
1044
  `)),console.log(u.bold("Recommended workflow:")),console.log(u.cyan(" npx rapidkit my-workspace")),console.log(u.cyan(" cd my-workspace")),console.log(u.cyan(" npx rapidkit create project fastapi.standard my-api --output .")),console.log(u.cyan(" cd my-api")),console.log(u.cyan(` npx rapidkit init && npx rapidkit dev
1045
1045
  `)),console.log(u.bold("Options (workspace creation):")),console.log(u.gray(" -y, --yes Skip prompts and use defaults")),console.log(u.gray(" --skip-git Skip git initialization")),console.log(u.gray(" --debug Enable debug logging")),console.log(u.gray(" --dry-run Show what would be created")),console.log(u.gray(" --create-workspace When creating a project outside a workspace: create and register a workspace in the current directory")),console.log(u.gray(" --no-workspace When creating a project outside a workspace: do not create a workspace")),console.log(u.gray(` --no-update-check Skip checking for updates
1046
1046
  `)),console.log(u.gray(`Tip: set RAPIDKIT_SHOW_LEGACY=1 to show legacy template flags in help.
1047
- `));}process.on("SIGINT",async()=>{if(!_e){if(_e=true,console.log(u.yellow(`
1047
+ `));}process.on("SIGINT",async()=>{if(!Ee){if(Ee=true,console.log(u.yellow(`
1048
1048
 
1049
- \u26A0\uFE0F Interrupted by user`)),J&&await k.pathExists(J)){console.log(u.gray("Cleaning up partial installation..."));try{await k.remove(J),console.log(u.green("\u2713 Cleanup complete"));}catch(e){a.debug("Cleanup failed:",e);}}process.exit(130);}});process.on("SIGTERM",async()=>{if(!_e){if(_e=true,a.debug("Received SIGTERM"),J&&await k.pathExists(J))try{await k.remove(J);}catch(e){a.debug("Cleanup failed:",e);}process.exit(143);}});Jo().then(async e=>{if(!e){let o=process.argv.slice(2);if(process.env.RAPIDKIT_NPM_DEBUG_ARGS==="1"&&process.stderr.write(`[rapidkit-npm] argv=${JSON.stringify(o)}
1050
- `),o[0]==="create"){let n=await Vo(o);process.exit(n);}if(o[0]==="init"){let n=await qo(o);process.exit(n);}let t=await Bo(o);if(process.env.RAPIDKIT_NPM_DEBUG_ARGS==="1"&&process.stderr.write(`[rapidkit-npm] shouldForwardToCore=${t}
1051
- `),t){let n=await d(o,{cwd:process.cwd()});process.exit(n);}V.parse();}});export{Vo as handleCreateOrFallback};
1049
+ \u26A0\uFE0F Interrupted by user`)),J&&await k.pathExists(J)){console.log(u.gray("Cleaning up partial installation..."));try{await k.remove(J),console.log(u.green("\u2713 Cleanup complete"));}catch(e){a.debug("Cleanup failed:",e);}}process.exit(130);}});process.on("SIGTERM",async()=>{if(!Ee){if(Ee=true,a.debug("Received SIGTERM"),J&&await k.pathExists(J))try{await k.remove(J);}catch(e){a.debug("Cleanup failed:",e);}process.exit(143);}});zo().then(async e=>{if(!e){let o=process.argv.slice(2);if(process.env.RAPIDKIT_NPM_DEBUG_ARGS==="1"&&process.stderr.write(`[rapidkit-npm] argv=${JSON.stringify(o)}
1050
+ `),o[0]==="create"){let n=await Uo(o);process.exit(n);}if(o[0]==="init"){let n=await Jo(o);process.exit(n);}let t=await Yo(o);if(process.env.RAPIDKIT_NPM_DEBUG_ARGS==="1"&&process.stderr.write(`[rapidkit-npm] shouldForwardToCore=${t}
1051
+ `),t){let n=await d(o,{cwd:process.cwd()});process.exit(n);}V.parse();}});export{Uo as handleCreateOrFallback};
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rapidkit",
3
- "version": "0.21.0",
3
+ "version": "0.21.2",
4
4
  "type": "module",
5
5
  "description": "Create RapidKit projects with a single command - The official CLI for RapidKit framework",
6
6
  "keywords": [
@@ -27,6 +27,7 @@
27
27
  "dist"
28
28
  ],
29
29
  "scripts": {
30
+ "preinstall": "node scripts/enforce-package-manager.cjs",
30
31
  "sync-kits": "bash scripts/sync-kits.sh",
31
32
  "build": "tsup",
32
33
  "build:watch": "tsup --watch",
@@ -62,7 +63,11 @@
62
63
  "size-check": "npm run build && size-limit",
63
64
  "bench": "npx tsx scripts/benchmarks.ts",
64
65
  "quality": "npm run typecheck && npm run lint && npm run format:check && npm test && npm run size-check",
65
- "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"
66
+ "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",
67
+ "release:dry": "bash scripts/release.sh --no-publish --yes --allow-dirty",
68
+ "release:patch": "bash scripts/release.sh patch",
69
+ "release:minor": "bash scripts/release.sh minor",
70
+ "release:major": "bash scripts/release.sh major"
66
71
  },
67
72
  "dependencies": {
68
73
  "chalk": "^5.3.0",
@@ -109,5 +114,5 @@
109
114
  "prettier --write"
110
115
  ]
111
116
  },
112
- "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
117
+ "packageManager": "npm@10.8.2"
113
118
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rapidkit",
3
- "version": "0.21.1",
3
+ "version": "0.21.2",
4
4
  "type": "module",
5
5
  "description": "Create RapidKit projects with a single command - The official CLI for RapidKit framework",
6
6
  "keywords": [
@@ -27,6 +27,7 @@
27
27
  "dist"
28
28
  ],
29
29
  "scripts": {
30
+ "preinstall": "node scripts/enforce-package-manager.cjs",
30
31
  "sync-kits": "bash scripts/sync-kits.sh",
31
32
  "build": "tsup",
32
33
  "build:watch": "tsup --watch",
@@ -62,7 +63,11 @@
62
63
  "size-check": "npm run build && size-limit",
63
64
  "bench": "npx tsx scripts/benchmarks.ts",
64
65
  "quality": "npm run typecheck && npm run lint && npm run format:check && npm test && npm run size-check",
65
- "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"
66
+ "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",
67
+ "release:dry": "bash scripts/release.sh --no-publish --yes --allow-dirty",
68
+ "release:patch": "bash scripts/release.sh patch",
69
+ "release:minor": "bash scripts/release.sh minor",
70
+ "release:major": "bash scripts/release.sh major"
66
71
  },
67
72
  "dependencies": {
68
73
  "chalk": "^5.3.0",
@@ -109,5 +114,5 @@
109
114
  "prettier --write"
110
115
  ]
111
116
  },
112
- "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
117
+ "packageManager": "npm@10.8.2"
113
118
  }